From 7d1d4c54049c5363cc6e518cbae02f93fdeb72a0 Mon Sep 17 00:00:00 2001 From: EmilianC Date: Sat, 20 Jul 2024 22:49:05 -0400 Subject: [PATCH] Reduced string operations when searching for JSON node names --- include/cereal/archives/json.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/cereal/archives/json.hpp b/include/cereal/archives/json.hpp index f86bcd40..564eebf2 100644 --- a/include/cereal/archives/json.hpp +++ b/include/cereal/archives/json.hpp @@ -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;