]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rgw_cors.cc: fix inefficient usage of string::find()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 2 Apr 2013 13:43:12 +0000 (15:43 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 2 Apr 2013 13:43:12 +0000 (15:43 +0200)
Fix warning from cppcheck:
 [src/rgw/rgw_cors.cc:70]: (performance) Inefficient usage of
 string::find() in condition; string::compare() would be faster.

Instead of string::find() use boost::algorithm::starts_with().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/rgw/rgw_cors.cc

index 76a031500a7c334d32f3c8c75f7d7e991cee58e2..033bfa2f215ea06b59a8781659500b177f739c8e 100644 (file)
@@ -16,6 +16,8 @@
 #include <iostream>
 #include <map>
 
+#include <boost/algorithm/string.hpp> 
+
 #include "include/types.h"
 #include "common/debug.h"
 #include "include/str_list.h"
@@ -67,7 +69,7 @@ static bool is_string_in_set(set<string>& s, string h) {
         string sl = ssplit.front();
         flen = sl.length();
         dout(10) << "Finding " << sl << ", in " << h << ", at offset 0" << dendl;
-        if (h.find(sl) != 0)
+        if (!boost::algorithm::starts_with(h,sl))
           continue;
         ssplit.pop_front();
       }