]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Interim: implement move constructor and tryto rework SBuf::compare
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 17 Feb 2015 17:46:12 +0000 (18:46 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 17 Feb 2015 17:46:12 +0000 (18:46 +0100)
src/SBuf.cc
src/SBuf.h

index 905dedf759752f43e930a73c553aaac4f414897b..8b79a3ec0679e47ba6abb344eda22208597e6fb2 100644 (file)
@@ -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;
index 12e7a2361fde2d2448de595e7f8814c503e02126..41b18a6041f6c323f6c5afbffb454515bc8919df 100644 (file)
@@ -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;
     }