hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1477541 - /httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
Date Tue, 30 Apr 2013 10:34:37 GMT
Author: olegk
Date: Tue Apr 30 10:34:34 2013
New Revision: 1477541

URL: http://svn.apache.org/r1477541
Log:
Performance optimization: use bulk ByteBuffer#put method instead of single byte ByteBuffer#put

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java?rev=1477541&r1=1477540&r2=1477541&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
Tue Apr 30 10:34:34 2013
@@ -177,8 +177,15 @@ public class SessionInputBufferImpl exte
         setOutputMode();
         final int len = Math.min(dst.remaining(), maxLen);
         final int chunk = Math.min(this.buffer.remaining(), len);
-        for (int i = 0; i < chunk; i++) {
-            dst.put(this.buffer.get());
+        if (this.buffer.remaining() > chunk) {
+            final int oldLimit = this.buffer.limit();
+            final int newLimit = this.buffer.position() + chunk;
+            this.buffer.limit(newLimit);
+            dst.put(this.buffer);
+            this.buffer.limit(oldLimit);
+            return len;
+        } else {
+            dst.put(this.buffer);
         }
         return chunk;
     }



Mime
View raw message