~kinkie/squid/sbuflab

« back to all changes in this revision

Viewing changes to src/SBuf.cc

  • Committer: Francesco Chemolli
  • Date: 2015-02-17 17:46:12 UTC
  • Revision ID: kinkie@squid-cache.org-20150217174612-3m989vlb568vnoa8
Interim: implement move constructor and tryto rework SBuf::compare

Show diffs side-by-side

added added

removed removed

Lines of Context:
365
365
int
366
366
SBuf::compare(const SBuf &S, const SBufCaseSensitive isCaseSensitive, const size_type n) const
367
367
{
368
 
    if (n != npos) {
369
 
        const SBuf s1 = substr(0,n);
370
 
        const SBuf s2 = S.substr(0,n);
371
 
        return s1.compare(s2,isCaseSensitive, n);
372
 
    }
 
368
    if (n != npos && (n > length() || n > S.length()))
 
369
        return substr(0,n).compare(S.substr(0,n),isCaseSensitive);
373
370
 
374
371
    const size_type byteCompareLen = min(S.length(), length());
375
372
    ++stats.compareSlow;