hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [30/50] httpcomponents-core git commit: Performance optimization: use bulk ByteBuffer#put method instead of single byte ByteBuffer#put
Date Tue, 09 May 2017 20:03:21 GMT
Performance optimization: use bulk ByteBuffer#put method instead of single byte ByteBuffer#put

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.2.x@1477535
13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/908b8dd0
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/908b8dd0
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/908b8dd0

Branch: refs/heads/4.2.x
Commit: 908b8dd0362726bfbd2dfabf0492b9e0bd900574
Parents: 005878d
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Tue Apr 30 10:32:18 2013 +0000
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Tue Apr 30 10:32:18 2013 +0000

----------------------------------------------------------------------
 .../http/impl/nio/reactor/SessionInputBufferImpl.java    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/908b8dd0/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
index 12f01d8..9eac7a7 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
@@ -110,8 +110,15 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements
SessionI
         setOutputMode();
         int len = Math.min(dst.remaining(), maxLen);
         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) {
+            int oldLimit = this.buffer.limit();
+            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