]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
pack header entries on cache updates
authorhno <>
Mon, 26 Nov 2007 20:09:54 +0000 (20:09 +0000)
committerhno <>
Mon, 26 Nov 2007 20:09:54 +0000 (20:09 +0000)
include/Array.h
src/HttpHeader.cc
src/HttpHeader.h
src/HttpReply.cc

index 93b7f893574d1ddd294cc217c4753dce27c1d2a5..28ac7d7cfddefa055e0a5b90441234481b2ae24d 100644 (file)
@@ -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<E>::back()
     return items[size() - 1];
 }
 
+template<class E>
+void
+Vector<E>::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<class E>
 void
index ef93f7c61333027c8f20a424715a8c66d710fc79..9e5b8867065c6d4aa4e226969a0bc2b75dae9f71 100644 (file)
@@ -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.
  */
index ddd3ac291560db7b56a5d20cfdc06e669e65abb2..2f67953654a6a0723c4468485cc886f49a27e65c 100644 (file)
@@ -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;
index 8bff5faf5998a7d12b88dcbaf49bbb1ca2e7a57d..36e97b3ed0af7d995bce7dc72203f53b69f86c98 100644 (file)
@@ -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();
 }