From: hno <> Date: Mon, 26 Nov 2007 20:09:54 +0000 (+0000) Subject: pack header entries on cache updates X-Git-Tag: SQUID_3_0_STABLE1~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=394499bdb72507c39d399473a106e5c812a02191;p=thirdparty%2Fsquid.git pack header entries on cache updates --- diff --git a/include/Array.h b/include/Array.h index 93b7f89357..28ac7d7cfd 100644 --- a/include/Array.h +++ b/include/Array.h @@ -1,5 +1,5 @@ /* - * $Id: Array.h,v 1.24 2005/11/21 22:43:41 wessels Exp $ + * $Id: Array.h,v 1.25 2007/11/26 13:09:54 hno Exp $ * * AUTHOR: Alex Rousskov * @@ -98,6 +98,7 @@ public: E &back(); E pop_back(); E shift(); // aka pop_front + void prune(E); void preAppend(int app_count); bool empty() const; size_t size() const; @@ -243,6 +244,22 @@ Vector::back() return items[size() - 1]; } +template +void +Vector::prune(E item) +{ + unsigned int n = 0; + for (unsigned int i = 0; i < count; i++) { + if (items[i] != item) { + if (i != n) + items[n] = items[i]; + n++; + } + } + + count = n; +} + /* if you are going to append a known and large number of items, call this first */ template void diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index ef93f7c613..9e5b886706 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.cc,v 1.137 2007/11/26 12:31:37 hno Exp $ + * $Id: HttpHeader.cc,v 1.138 2007/11/26 13:09:55 hno Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -786,6 +786,15 @@ HttpHeader::delAt(HttpHeaderPos pos, int &headers_deleted) ++headers_deleted; } +/* + * Compacts the header storage + */ +void +HttpHeader::compact() +{ + entries.prune(NULL); +} + /* * Refreshes the header mask. Required after delAt() calls. */ diff --git a/src/HttpHeader.h b/src/HttpHeader.h index ddd3ac2915..2f67953654 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.h,v 1.23 2007/08/13 17:20:51 hno Exp $ + * $Id: HttpHeader.h,v 1.24 2007/11/26 13:09:55 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -202,6 +202,7 @@ public: void clean(); void append(const HttpHeader * src); void update (HttpHeader const *fresh, HttpHeaderMask const *denied_mask); + void compact(); int reset(); int parse(const char *header_start, const char *header_end); void packInto(Packer * p) const; diff --git a/src/HttpReply.cc b/src/HttpReply.cc index 8bff5faf59..36e97b3ed0 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.96 2007/08/13 17:20:51 hno Exp $ + * $Id: HttpReply.cc,v 1.97 2007/11/26 13:09:55 hno Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -312,6 +312,7 @@ HttpReply::updateOnNotModified(HttpReply const * freshRep) header.update(&freshRep->header, (const HttpHeaderMask *) &Denied304HeadersMask); + header.compact(); /* init cache */ hdrCacheInit(); }