From: Francesco Chemolli Date: Tue, 17 Feb 2015 17:46:12 +0000 (+0100) Subject: Interim: implement move constructor and tryto rework SBuf::compare X-Git-Tag: merge-candidate-3-v1~258^2~4 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=e1c19450e1b95976a4398b51dd7f3cdbd5fdee30;p=thirdparty%2Fsquid.git Interim: implement move constructor and tryto rework SBuf::compare --- diff --git a/src/SBuf.cc b/src/SBuf.cc index 905dedf759..8b79a3ec06 100644 --- a/src/SBuf.cc +++ b/src/SBuf.cc @@ -365,11 +365,8 @@ memcasecmp(const char *b1, const char *b2, SBuf::size_type len) int SBuf::compare(const SBuf &S, const SBufCaseSensitive isCaseSensitive, const size_type n) const { - if (n != npos) { - const SBuf s1 = substr(0,n); - const SBuf s2 = S.substr(0,n); - return s1.compare(s2,isCaseSensitive, n); - } + if (n != npos && (n > length() || n > S.length())) + return substr(0,n).compare(S.substr(0,n),isCaseSensitive); const size_type byteCompareLen = min(S.length(), length()); ++stats.compareSlow; diff --git a/src/SBuf.h b/src/SBuf.h index 12e7a2361f..41b18a6041 100644 --- a/src/SBuf.h +++ b/src/SBuf.h @@ -135,8 +135,7 @@ public: /// create an empty (zero-size) SBuf SBuf(); SBuf(const SBuf &S); - SBuf(SBuf&& S) { - store_=S.store_; off_=S.off_; len_=S.len_; + SBuf(SBuf&& S) : store_(std::move(S.store_)), off_(S.off_), len_(S.len_) { S.store_=GetStorePrototype(); S.off_=0; S.len_=0; }