Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 71411 invoked from network); 19 Nov 2008 22:15:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Nov 2008 22:15:15 -0000 Received: (qmail 37553 invoked by uid 500); 19 Nov 2008 22:15:17 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 37461 invoked by uid 500); 19 Nov 2008 22:15:17 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 37449 invoked by uid 99); 19 Nov 2008 22:15:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Nov 2008 14:15:17 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Nov 2008 22:14:02 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D59B22388886; Wed, 19 Nov 2008 14:14:47 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r719092 - in /tomcat/trunk/java/org/apache/tomcat/util/collections: MultiMap.java MultiMapNamesEnumeration.java MultiMapValuesEnumeration.java Date: Wed, 19 Nov 2008 22:14:47 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081119221447.D59B22388886@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Wed Nov 19 14:14:47 2008 New Revision: 719092 URL: http://svn.apache.org/viewvc?rev=719092&view=rev Log: Tab police Modified: tomcat/trunk/java/org/apache/tomcat/util/collections/MultiMap.java tomcat/trunk/java/org/apache/tomcat/util/collections/MultiMapNamesEnumeration.java tomcat/trunk/java/org/apache/tomcat/util/collections/MultiMapValuesEnumeration.java Modified: tomcat/trunk/java/org/apache/tomcat/util/collections/MultiMap.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/collections/MultiMap.java?rev=719092&r1=719091&r2=719092&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/collections/MultiMap.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/collections/MultiMap.java Wed Nov 19 14:14:47 2008 @@ -50,17 +50,17 @@ * */ public MultiMap(int initial_size) { - fields=new Field[initial_size]; + fields=new Field[initial_size]; } /** * Clears all header fields. */ public void recycle() { - for (int i = 0; i < count; i++) { - fields[i].recycle(); - } - count = 0; + for (int i = 0; i < count; i++) { + fields[i].recycle(); + } + count = 0; } // -------------------- Idx access to headers ---------- @@ -70,7 +70,7 @@ * Returns the current number of header fields. */ public int size() { - return count; + return count; } /** @@ -80,8 +80,8 @@ * An exception is thrown if the index is not valid ( <0 or >size ) */ public MessageBytes getName(int n) { - // n >= 0 && n < count ? headers[n].getName() : null - return fields[n].name; + // n >= 0 && n < count ? headers[n].getName() : null + return fields[n].name; } /** @@ -89,21 +89,21 @@ * This may be used to iterate through all header fields. */ public MessageBytes getValue(int n) { - return fields[n].value; + return fields[n].value; } /** Find the index of a field with the given name. */ public int find( String name, int starting ) { - // We can use a hash - but it's not clear how much - // benefit you can get - there is an overhead - // and the number of headers is small (4-5 ?) - // Another problem is that we'll pay the overhead - // of constructing the hashtable + // We can use a hash - but it's not clear how much + // benefit you can get - there is an overhead + // and the number of headers is small (4-5 ?) + // Another problem is that we'll pay the overhead + // of constructing the hashtable - // A custom search tree may be better + // A custom search tree may be better for (int i = starting; i < count; i++) { - if (fields[i].name.equals(name)) { + if (fields[i].name.equals(name)) { return i; } } @@ -113,15 +113,15 @@ /** Find the index of a field with the given name. */ public int findIgnoreCase( String name, int starting ) { - // We can use a hash - but it's not clear how much - // benefit you can get - there is an overhead - // and the number of headers is small (4-5 ?) - // Another problem is that we'll pay the overhead - // of constructing the hashtable + // We can use a hash - but it's not clear how much + // benefit you can get - there is an overhead + // and the number of headers is small (4-5 ?) + // Another problem is that we'll pay the overhead + // of constructing the hashtable - // A custom search tree may be better + // A custom search tree may be better for (int i = starting; i < count; i++) { - if (fields[i].name.equalsIgnoreCase(name)) { + if (fields[i].name.equalsIgnoreCase(name)) { return i; } } @@ -139,68 +139,68 @@ * there are better ways ( like adding a "isValid" field ) */ public void remove( int i ) { - // reset and swap with last header - Field mh = fields[i]; - // reset the field - mh.recycle(); - - fields[i] = fields[count - 1]; - fields[count - 1] = mh; - count--; + // reset and swap with last header + Field mh = fields[i]; + // reset the field + mh.recycle(); + + fields[i] = fields[count - 1]; + fields[count - 1] = mh; + count--; } /** Create a new, unitialized entry. */ public int addField() { - int len = fields.length; - int pos=count; - if (count >= len) { - // expand header list array - Field tmp[] = new Field[pos * 2]; - System.arraycopy(fields, 0, tmp, 0, len); - fields = tmp; - } - if (fields[pos] == null) { - fields[pos] = new Field(); - } - count++; - return pos; + int len = fields.length; + int pos=count; + if (count >= len) { + // expand header list array + Field tmp[] = new Field[pos * 2]; + System.arraycopy(fields, 0, tmp, 0, len); + fields = tmp; + } + if (fields[pos] == null) { + fields[pos] = new Field(); + } + count++; + return pos; } public MessageBytes get( String name) { for (int i = 0; i < count; i++) { - if (fields[i].name.equals(name)) { - return fields[i].value; - } - } + if (fields[i].name.equals(name)) { + return fields[i].value; + } + } return null; } public int findFirst( String name ) { for (int i = 0; i < count; i++) { - if (fields[i].name.equals(name)) { - return i; - } - } + if (fields[i].name.equals(name)) { + return i; + } + } return -1; } public int findNext( int startPos ) { - int next= fields[startPos].nextPos; - if( next != MultiMap.NEED_NEXT ) { - return next; - } + int next= fields[startPos].nextPos; + if( next != MultiMap.NEED_NEXT ) { + return next; + } - // next==NEED_NEXT, we never searched for this header - MessageBytes name=fields[startPos].name; + // next==NEED_NEXT, we never searched for this header + MessageBytes name=fields[startPos].name; for (int i = startPos; i < count; i++) { - if (fields[i].name.equals(name)) { - // cache the search result - fields[startPos].nextPos=i; - return i; - } - } - fields[startPos].nextPos= MultiMap.LAST; + if (fields[i].name.equals(name)) { + // cache the search result + fields[startPos].nextPos=i; + return i; + } + } + fields[startPos].nextPos= MultiMap.LAST; return -1; } @@ -210,27 +210,27 @@ // -------------------- Internal representation -------------------- final class Field { - MessageBytes name; - MessageBytes value; + MessageBytes name; + MessageBytes value; + + // Extra info for speed + + // multiple fields with same name - a linked list will + // speed up multiple name enumerations and search. + int nextPos; + + // hashkey + int hash; + Field nextSameHash; - // Extra info for speed - - // multiple fields with same name - a linked list will - // speed up multiple name enumerations and search. - int nextPos; - - // hashkey - int hash; - Field nextSameHash; - - Field() { - nextPos=MultiMap.NEED_NEXT; - } - - void recycle() { - name.recycle(); - value.recycle(); - nextPos=MultiMap.NEED_NEXT; - } + Field() { + nextPos=MultiMap.NEED_NEXT; + } + + void recycle() { + name.recycle(); + value.recycle(); + nextPos=MultiMap.NEED_NEXT; + } } } Modified: tomcat/trunk/java/org/apache/tomcat/util/collections/MultiMapNamesEnumeration.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/collections/MultiMapNamesEnumeration.java?rev=719092&r1=719091&r2=719092&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/collections/MultiMapNamesEnumeration.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/collections/MultiMapNamesEnumeration.java Wed Nov 19 14:14:47 2008 @@ -41,41 +41,41 @@ * @param unique return only unique names */ MultiMapNamesEnumeration(MultiMap headers, boolean toString, - boolean unique) { - this.headers=headers; - pos=0; - size = headers.size(); - findNext(); + boolean unique) { + this.headers=headers; + pos=0; + size = headers.size(); + findNext(); } private void findNext() { - next=null; - for( ; pos< size; pos++ ) { - next=headers.getName( pos ).toString(); - for( int j=0; j