hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1544961 - /httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/HeaderGroup.java
Date Sun, 24 Nov 2013 11:47:23 GMT
Author: olegk
Date: Sun Nov 24 11:47:22 2013
New Revision: 1544961

URL: http://svn.apache.org/r1544961
Log:
HTTPCORE-361: Reduced intermediate garbage generated by for-each loops

Modified:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/HeaderGroup.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/HeaderGroup.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/HeaderGroup.java?rev=1544961&r1=1544960&r2=1544961&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/HeaderGroup.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/HeaderGroup.java
Sun Nov 24 11:47:22 2013
@@ -171,8 +171,8 @@ public class HeaderGroup implements Clon
      */
     public Header[] getHeaders(final String name) {
         final List<Header> headersFound = new ArrayList<Header>();
-
-        for (final Header header : headers) {
+        for (int i = 0; i < this.headers.size(); i++) {
+            final Header header = this.headers.get(i);
             if (header.getName().equalsIgnoreCase(name)) {
                 headersFound.add(header);
             }
@@ -190,7 +190,7 @@ public class HeaderGroup implements Clon
      * @return the first header or <code>null</code>
      */
     public Header getFirstHeader(final String name) {
-        // HTTPCORE-361 : we don't use the for-each syntax, i.e. 
+        // HTTPCORE-361 : we don't use the for-each syntax, i.e.
         //     for (Header header : headers)
         // as that creates an Iterator that needs to be garbage-collected
         for (int i = 0; i < this.headers.size(); i++) {
@@ -241,7 +241,8 @@ public class HeaderGroup implements Clon
      * contained, <code>false</code> otherwise
      */
     public boolean containsHeader(final String name) {
-        for (final Header header : headers) {
+        for (int i = 0; i < this.headers.size(); i++) {
+            final Header header = this.headers.get(i);
             if (header.getName().equalsIgnoreCase(name)) {
                 return true;
             }



Mime
View raw message