~yadi/squid/parser-ng-htok

« back to all changes in this revision

Viewing changes to src/SBuf.cc

  • Committer: Amos Jeffries
  • Date: 2015-03-17 02:51:04 UTC
  • Revision ID: squid3@treenet.co.nz-20150317025104-c248f3dd2y0v8lk6
Polish rev.13980 debugs

Show diffs side-by-side

added added

removed removed

Lines of Context:
182
182
    // it's available, we're effectively claiming ownership
183
183
    // of it. If it's not, we need to go away (realloc)
184
184
    if (store_->canAppend(off_+len_, minSpace)) {
185
 
        debugs(24, 7, id << "not growing");
 
185
        debugs(24, 7, id << " not growing");
186
186
        return bufEnd();
187
187
    }
188
188
    // TODO: we may try to memmove before realloc'ing in order to avoid
508
508
        n = length();
509
509
    else
510
510
        n = min(n, length());
511
 
    debugs(24, 8, id << "consume " << n);
 
511
    debugs(24, 8, id << " consume " << n);
512
512
    SBuf rv(substr(0, n));
513
513
    chop(n);
514
514
    return rv;
539
539
void
540
540
SBuf::forceSize(size_type newSize)
541
541
{
542
 
    debugs(24, 8, id << "force " << (newSize > length() ? "grow" : "shrink") << " to length=" << newSize);
 
542
    debugs(24, 8, id << " force " << (newSize > length() ? "grow" : "shrink") << " to length=" << newSize);
543
543
 
544
544
    Must(store_->LockCount() == 1);
545
545
    if (newSize > min(maxSize,store_->capacity-off_))
904
904
void
905
905
SBuf::reAlloc(size_type newsize)
906
906
{
907
 
    debugs(24, 8, id << "new size: " << newsize);
 
907
    debugs(24, 8, id << " new size: " << newsize);
908
908
    if (newsize > maxSize)
909
909
        throw SBufTooBigException(__FILE__, __LINE__);
910
910
    MemBlob::Pointer newbuf = new MemBlob(newsize);
913
913
    store_ = newbuf;
914
914
    off_ = 0;
915
915
    ++stats.cowSlow;
916
 
    debugs(24, 7, id << "new store capacity: " << store_->capacity);
 
916
    debugs(24, 7, id << " new store capacity: " << store_->capacity);
917
917
}
918
918
 
919
919
SBuf&
934
934
void
935
935
SBuf::cow(SBuf::size_type newsize)
936
936
{
937
 
    debugs(24, 8, id << "new size:" << newsize);
 
937
    debugs(24, 8, id << " new size:" << newsize);
938
938
    if (newsize == npos || newsize < length())
939
939
        newsize = length();
940
940
 
941
941
    if (store_->LockCount() == 1 && newsize == length()) {
942
 
        debugs(24, 8, id << "no cow needed");
 
942
        debugs(24, 8, id << " no cow needed");
943
943
        ++stats.cowFast;
944
944
        return;
945
945
    }