summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-07-28 10:09:48 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-07-31 17:29:17 +0200
commit5aed763bc1faeb00cdef1473587448c03b75edb3 (patch)
treef6d1b790afca2134efdc44b22c064b3d9ab959b2 /document
parentf1bf27f41ec655cf6d5c097daef4dbcebf6ef666 (diff)
Move forward and copy memory when necessary, not for every char.
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/base/fieldpath.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/document/src/vespa/document/base/fieldpath.cpp b/document/src/vespa/document/base/fieldpath.cpp
index 0d43413e696..6625f9ae2a5 100644
--- a/document/src/vespa/document/base/fieldpath.cpp
+++ b/document/src/vespa/document/base/fieldpath.cpp
@@ -145,23 +145,25 @@ vespalib::string FieldPathEntry::parseKey(vespalib::stringref & key)
if ((c < e) && (c[0] == '{')) {
for(c++;(c < e) && isspace(c[0]); c++);
if ((c < e) && (c[0] == '"')) {
- for (c++; (c < e) && (c[0] != '"'); c++) {
+ const char * start = ++c;
+ for (; (c < e) && (c[0] != '"'); c++) {
if (c[0] == '\\') {
- c++;
- }
- if (c < e) {
- v += c[0];
+ v.append(start, c-start);
+ start = ++c;
}
}
+ v.append(start, c-start);
if ((c < e) && (c[0] == '"')) {
c++;
} else {
throw IllegalArgumentException(make_string("Escaped key '%s' is incomplete. No matching '\"'", key.c_str()), VESPA_STRLOC);
}
} else {
- for (;(c < e) && (c[0] != '}'); c++) {
- v += c[0];
+ const char * start = c;
+ while ((c < e) && (c[0] != '}')) {
+ c++;
}
+ v.append(start, c-start);
}
for(;(c < e) && isspace(c[0]); c++);
if ((c < e) && (c[0] == '}')) {