Skip to content

Commit 0552335

Browse files
authored
Fixing the issue. (simdjson#1151)
1 parent 7aea774 commit 0552335

File tree

5 files changed

+840
-1026
lines changed

5 files changed

+840
-1026
lines changed

include/simdjson/dom/array-inl.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,10 @@ inline size_t array::size() const noexcept {
6262
return tape.scope_count();
6363
}
6464
inline simdjson_result<element> array::at_pointer(std::string_view json_pointer) const noexcept {
65-
if(json_pointer[0] != '/') {
66-
if(json_pointer.empty()) { // an empty string means that we return the current node
65+
if(json_pointer.empty()) { // an empty string means that we return the current node
6766
return element(this->tape); // copy the current node
68-
} else { // otherwise there is an error
67+
} else if(json_pointer[0] != '/') { // otherwise there is an error
6968
return INVALID_JSON_POINTER;
70-
}
7169
}
7270
json_pointer = json_pointer.substr(1);
7371
// - means "the append position" or "the element after the end of the array"
@@ -102,6 +100,7 @@ inline simdjson_result<element> array::at_pointer(std::string_view json_pointer)
102100
}
103101
return child;
104102
}
103+
105104
inline simdjson_result<element> array::at(size_t index) const noexcept {
106105
size_t i=0;
107106
for (auto element : *this) {

include/simdjson/dom/object-inl.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,10 @@ inline simdjson_result<element> object::operator[](const char *key) const noexce
8181
return at_key(key);
8282
}
8383
inline simdjson_result<element> object::at_pointer(std::string_view json_pointer) const noexcept {
84-
if(json_pointer[0] != '/') {
85-
if(json_pointer.empty()) { // an empty string means that we return the current node
84+
if(json_pointer.empty()) { // an empty string means that we return the current node
8685
return element(this->tape); // copy the current node
87-
} else { // otherwise there is an error
86+
} else if(json_pointer[0] != '/') { // otherwise there is an error
8887
return INVALID_JSON_POINTER;
89-
}
9088
}
9189
json_pointer = json_pointer.substr(1);
9290
size_t slash = json_pointer.find('/');

0 commit comments

Comments
 (0)