Skip to content

Commit 122179a

Browse files
committed
Reduced string operations when searching for JSON node names
1 parent d1fcec8 commit 122179a

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

include/cereal/archives/json.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,13 +539,11 @@ namespace cereal
539539
/*! @throws Exception if no such named node exists */
540540
inline void search( const char * searchName )
541541
{
542-
const auto len = std::strlen( searchName );
543542
size_t index = 0;
544543
for( auto it = itsMemberItBegin; it != itsMemberItEnd; ++it, ++index )
545544
{
546545
const auto currentName = it->name.GetString();
547-
if( ( std::strncmp( searchName, currentName, len ) == 0 ) &&
548-
( std::strlen( currentName ) == len ) )
546+
if( std::strcmp( searchName, currentName, len ) == 0 )
549547
{
550548
itsIndex = index;
551549
return;

0 commit comments

Comments
 (0)