From: Francesco Chemolli Date: Mon, 16 Feb 2015 16:19:19 +0000 (+0100) Subject: Interim: implement SBuf move constructor, TODO: fix SBuf::compare X-Git-Tag: merge-candidate-3-v1~258^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f49df3f542909c8cb55ee3cbab56b5146fc3d063;p=thirdparty%2Fsquid.git Interim: implement SBuf move constructor, TODO: fix SBuf::compare --- diff --git a/src/SBuf.cc b/src/SBuf.cc index 1468192835..905dedf759 100644 --- a/src/SBuf.cc +++ b/src/SBuf.cc @@ -365,8 +365,11 @@ 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) - return substr(0,n).compare(S.substr(0,n),isCaseSensitive); + if (n != npos) { + const SBuf s1 = substr(0,n); + const SBuf s2 = S.substr(0,n); + return s1.compare(s2,isCaseSensitive, n); + } const size_type byteCompareLen = min(S.length(), length()); ++stats.compareSlow; diff --git a/src/SBuf.h b/src/SBuf.h index 58af282be8..12e7a2361f 100644 --- a/src/SBuf.h +++ b/src/SBuf.h @@ -135,6 +135,10 @@ public: /// create an empty (zero-size) SBuf SBuf(); SBuf(const SBuf &S); + SBuf(SBuf&& S) { + store_=S.store_; off_=S.off_; len_=S.len_; + S.store_=GetStorePrototype(); S.off_=0; S.len_=0; + } /** Constructor: import c-style string *