]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Interim: implement SBuf move constructor, TODO: fix SBuf::compare
authorFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 16 Feb 2015 16:19:19 +0000 (17:19 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 16 Feb 2015 16:19:19 +0000 (17:19 +0100)
src/SBuf.cc
src/SBuf.h

index 146819283543f41bc8b57c8c1a3424360952db3f..905dedf759752f43e930a73c553aaac4f414897b 100644 (file)
@@ -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;
index 58af282be84e1e3355eae371afbdeb79b5cb7eaa..12e7a2361fde2d2448de595e7f8814c503e02126 100644 (file)
@@ -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
      *