hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [01/42] httpcomponents-core git commit: Refactor magic number. [Forced Update!]
Date Thu, 11 May 2017 18:17:36 GMT
Repository: httpcomponents-core
Updated Branches:
  refs/heads/4.4.x 729835bc8 -> 6678c9502 (forced update)


Refactor magic number.


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

Branch: refs/heads/4.4.x
Commit: e1f4777d93b01eaf415ebb93ac9ca984d21921d1
Parents: a15ca59
Author: Gary D. Gregory <ggregory@apache.org>
Authored: Wed Jan 11 23:44:17 2017 +0000
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Thu May 11 20:16:29 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/http/util/EntityUtils.java  | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e1f4777d/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/util/EntityUtils.java b/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
index 83297f0..ac795b2 100644
--- a/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
+++ b/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
@@ -50,6 +50,8 @@ import org.apache.http.protocol.HTTP;
  */
 public final class EntityUtils {
 
+    private static final int DEFAULT_BUFFER_SIZE = 4096;
+
     private EntityUtils() {
     }
 
@@ -126,12 +128,12 @@ public final class EntityUtils {
         try {
             Args.check(entity.getContentLength() <= Integer.MAX_VALUE,
                     "HTTP entity too large to be buffered in memory");
-            int i = (int)entity.getContentLength();
-            if (i < 0) {
-                i = 4096;
+            int capacity = (int)entity.getContentLength();
+            if (capacity < 0) {
+                capacity = DEFAULT_BUFFER_SIZE;
             }
-            final ByteArrayBuffer buffer = new ByteArrayBuffer(i);
-            final byte[] tmp = new byte[4096];
+            final ByteArrayBuffer buffer = new ByteArrayBuffer(capacity);
+            final byte[] tmp = new byte[DEFAULT_BUFFER_SIZE];
             int l;
             while((l = instream.read(tmp)) != -1) {
                 buffer.append(tmp, 0, l);
@@ -203,9 +205,9 @@ public final class EntityUtils {
         try {
             Args.check(entity.getContentLength() <= Integer.MAX_VALUE,
                     "HTTP entity too large to be buffered in memory");
-            int i = (int)entity.getContentLength();
-            if (i < 0) {
-                i = 4096;
+            int capacity = (int)entity.getContentLength();
+            if (capacity < 0) {
+                capacity = DEFAULT_BUFFER_SIZE;
             }
             Charset charset = null;
             if (contentType != null) {
@@ -219,7 +221,7 @@ public final class EntityUtils {
                 charset = HTTP.DEF_CONTENT_CHARSET;
             }
             final Reader reader = new InputStreamReader(instream, charset);
-            final CharArrayBuffer buffer = new CharArrayBuffer(i);
+            final CharArrayBuffer buffer = new CharArrayBuffer(capacity);
             final char[] tmp = new char[1024];
             int l;
             while((l = reader.read(tmp)) != -1) {


Mime
View raw message