Skip to content

Commit fafeb49

Browse files
committed
Reduced string operations when searching for JSON node names
USCiLab/cereal#826
1 parent 1459eab commit fafeb49

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

include/vide/archives/json.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,10 @@ class JSONInputArchive : public InputArchive<JSONInputArchive, vide::TextArchive
537537
//! Adjust our position such that we are at the node with the given name
538538
/*! @throws Exception if no such named node exists */
539539
inline void search(const char* searchName) {
540-
const auto len = std::strlen(searchName);
541540
size_t index = 0;
542541
for (auto it = itsMemberItBegin; it != itsMemberItEnd; ++it, ++index) {
543542
const auto currentName = it->name.GetString();
544-
if ((std::strncmp(searchName, currentName, len) == 0) &&
545-
(std::strlen(currentName) == len)) {
543+
if (std::strcmp(searchName, currentName) == 0) {
546544
itsIndex = index;
547545
return;
548546
}

0 commit comments

Comments
 (0)