Skip to content

Commit

Permalink
Reduced string operations when searching for JSON node names
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilianC committed Jul 21, 2024
1 parent d1fcec8 commit 7d1d4c5
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions include/cereal/archives/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,11 @@ namespace cereal
/*! @throws Exception if no such named node exists */
inline void search( const char * searchName )
{
const auto len = std::strlen( searchName );
size_t index = 0;
for( auto it = itsMemberItBegin; it != itsMemberItEnd; ++it, ++index )
{
const auto currentName = it->name.GetString();
if( ( std::strncmp( searchName, currentName, len ) == 0 ) &&
( std::strlen( currentName ) == len ) )
if( std::strcmp( searchName, currentName ) == 0 )
{
itsIndex = index;
return;
Expand Down

0 comments on commit 7d1d4c5

Please sign in to comment.