From: Danny Al-Gaaf Date: Tue, 2 Apr 2013 13:43:12 +0000 (+0200) Subject: rgw/rgw_cors.cc: fix inefficient usage of string::find() X-Git-Tag: v0.62~102^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7abba7b1923cf97fbc5d47a8ffc4b7f56bd6b3db;p=ceph.git rgw/rgw_cors.cc: fix inefficient usage of string::find() 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 --- diff --git a/src/rgw/rgw_cors.cc b/src/rgw/rgw_cors.cc index 76a031500a7c..033bfa2f215e 100644 --- a/src/rgw/rgw_cors.cc +++ b/src/rgw/rgw_cors.cc @@ -16,6 +16,8 @@ #include #include +#include + #include "include/types.h" #include "common/debug.h" #include "include/str_list.h" @@ -67,7 +69,7 @@ static bool is_string_in_set(set& 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(); }