From f10f4a64f70b0b1ef5b48a87e8dcdf96c91d429b Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Wed, 16 Dec 2020 16:19:55 +0100 Subject: [PATCH] Optimize calls to std::string::find() and friends for a single char. The character literal overload is more efficient. More info at: http://clang.llvm.org/extra/clang-tidy/checks/performance-faster-string-find.html --- modules/tracking/src/trackerFeature.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tracking/src/trackerFeature.cpp b/modules/tracking/src/trackerFeature.cpp index a5b59bdcf..9610fe528 100644 --- a/modules/tracking/src/trackerFeature.cpp +++ b/modules/tracking/src/trackerFeature.cpp @@ -65,8 +65,8 @@ Ptr TrackerFeature::create( const String& trackerFeatureType ) { if( trackerFeatureType.find( "FEATURE2D" ) == 0 ) { - size_t firstSep = trackerFeatureType.find_first_of( "." ); - size_t secondSep = trackerFeatureType.find_last_of( "." ); + size_t firstSep = trackerFeatureType.find_first_of('.'); + size_t secondSep = trackerFeatureType.find_last_of('.'); String detector = trackerFeatureType.substr( firstSep, secondSep - firstSep ); String descriptor = trackerFeatureType.substr( secondSep, trackerFeatureType.length() - secondSep );