Use a.rfind(b, 0) == 0 instead of a.find(b) == 0 to reduce processing time when checking that a starts wit b, #1459

This commit is contained in:
Ingo Weyrich
2021-01-26 18:41:30 +01:00
parent aa43be4782
commit a6a47346a8
3 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -275,7 +275,7 @@ namespace Exiv2 {
, { "-" ,pStdin , false }
};
for ( size_t i = 0 ; result == pFile && i < sizeof(prots)/sizeof(prots[0]) ; i ++ )
if ( path.find(prots[i].name) == 0 )
if ( path.rfind(prots[i].name, 0) == 0 )
// URL's require data. Stdin == "-" and no further data
if ( prots[i].isUrl ? path.size() > prots[i].name.size() : path.size() == prots[i].name.size() )
result = prots[i].prot;
@@ -300,7 +300,7 @@ namespace Exiv2 {
, { L"-" ,pStdin , false }
};
for ( size_t i = 0 ; result == pFile && i < sizeof(prots)/sizeof(prots[0]) ; i ++ )
if ( path.find(prots[i].name) == 0 )
if ( path.rfind(prots[i].name, 0) == 0 )
// URL's require data. Stdin == "-" and no further data
if ( prots[i].isUrl ? path.size() > prots[i].name.size() : path.size() == prots[i].name.size() )
result = prots[i].prot;