You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2021/01/25 19:02:00 UTC

[GitHub] [httpcomponents-core] arturobernalg opened a new pull request #247: Minor Improvement:

arturobernalg opened a new pull request #247:
URL: https://github.com/apache/httpcomponents-core/pull/247


   * Use Empty collections
   * Unnecessary boxing
   * Unnecessary toString
   * Use Math.max


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-core] arturobernalg commented on a change in pull request #247: Minor Improvement:

Posted by GitBox <gi...@apache.org>.
arturobernalg commented on a change in pull request #247:
URL: https://github.com/apache/httpcomponents-core/pull/247#discussion_r563979466



##########
File path: httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java
##########
@@ -105,6 +105,11 @@
     public static final ContentType WILDCARD = create(
             "*/*", (Charset) null);
 
+    /**
+     * An empty immutable {@code NameValuePair} array.
+     */
+    public static final NameValuePair[] EMPTY_NAME_VALUE_PAIR_ARRAY = new NameValuePair[0];

Review comment:
       Ok. changed 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-core] ok2c commented on a change in pull request #247: Minor Improvement:

Posted by GitBox <gi...@apache.org>.
ok2c commented on a change in pull request #247:
URL: https://github.com/apache/httpcomponents-core/pull/247#discussion_r563974834



##########
File path: httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java
##########
@@ -105,6 +105,11 @@
     public static final ContentType WILDCARD = create(
             "*/*", (Charset) null);
 
+    /**
+     * An empty immutable {@code NameValuePair} array.
+     */
+    public static final NameValuePair[] EMPTY_NAME_VALUE_PAIR_ARRAY = new NameValuePair[0];

Review comment:
       @arturobernalg There is no need to make it public. Please change to private.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-core] arturobernalg commented on a change in pull request #247: Minor Improvement:

Posted by GitBox <gi...@apache.org>.
arturobernalg commented on a change in pull request #247:
URL: https://github.com/apache/httpcomponents-core/pull/247#discussion_r564222715



##########
File path: httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/ServerBootstrap.java
##########
@@ -407,7 +407,7 @@ public HttpServer create() {
         }
 
         return new HttpServer(
-                this.listenerPort > 0 ? this.listenerPort : 0,
+                Math.max(this.listenerPort, 0),

Review comment:
       > @arturobernalg What are benefits of using `Math#max` here? Is it more byte code efficient? I am kind of old and stupid. It makes it more difficult for me to understand the intent of the operation. I am also a bit worried that the proposed code appears to make no distinction between greater and greater equal (as well lesser and lesser equal) comparison operations.
   
   HI @ok2c 
   My idea was get more readability. As far as I know for implementation/performance sake, they would be nearly equivalent. Maybe a bit more faster the java implementations. But your right,  no make no distinction between greater and greater equal. I gonna remove that changes. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-core] ok2c commented on a change in pull request #247: Minor Improvement:

Posted by GitBox <gi...@apache.org>.
ok2c commented on a change in pull request #247:
URL: https://github.com/apache/httpcomponents-core/pull/247#discussion_r563974834



##########
File path: httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java
##########
@@ -105,6 +105,11 @@
     public static final ContentType WILDCARD = create(
             "*/*", (Charset) null);
 
+    /**
+     * An empty immutable {@code NameValuePair} array.
+     */
+    public static final NameValuePair[] EMPTY_NAME_VALUE_PAIR_ARRAY = new NameValuePair[0];

Review comment:
       @arturobernalg There is no need to make it public. Please change to private.

##########
File path: httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/ServerBootstrap.java
##########
@@ -407,7 +407,7 @@ public HttpServer create() {
         }
 
         return new HttpServer(
-                this.listenerPort > 0 ? this.listenerPort : 0,
+                Math.max(this.listenerPort, 0),

Review comment:
       @arturobernalg What are benefits of using `Math#max` here? Is it more byte code efficient? I am kind of old and stupid. It makes it more difficult for me to understand the intent of the operation. I am also a bit worried that the proposed code appears to make no distinction between greater and greater equal (as well lesser and lesser equal) comparison operations.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-core] ok2c commented on a change in pull request #247: Minor Improvement:

Posted by GitBox <gi...@apache.org>.
ok2c commented on a change in pull request #247:
URL: https://github.com/apache/httpcomponents-core/pull/247#discussion_r563993361



##########
File path: httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/ServerBootstrap.java
##########
@@ -407,7 +407,7 @@ public HttpServer create() {
         }
 
         return new HttpServer(
-                this.listenerPort > 0 ? this.listenerPort : 0,
+                Math.max(this.listenerPort, 0),

Review comment:
       @arturobernalg What are benefits of using `Math#max` here? Is it more byte code efficient? I am kind of old and stupid. It makes it more difficult for me to understand the intent of the operation. I am also a bit worried that the proposed code appears to make no distinction between greater and greater equal (as well lesser and lesser equal) comparison operations.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-core] ok2c merged pull request #247: Minor Improvement:

Posted by GitBox <gi...@apache.org>.
ok2c merged pull request #247:
URL: https://github.com/apache/httpcomponents-core/pull/247


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-core] arturobernalg commented on a change in pull request #247: Minor Improvement:

Posted by GitBox <gi...@apache.org>.
arturobernalg commented on a change in pull request #247:
URL: https://github.com/apache/httpcomponents-core/pull/247#discussion_r563979466



##########
File path: httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java
##########
@@ -105,6 +105,11 @@
     public static final ContentType WILDCARD = create(
             "*/*", (Charset) null);
 
+    /**
+     * An empty immutable {@code NameValuePair} array.
+     */
+    public static final NameValuePair[] EMPTY_NAME_VALUE_PAIR_ARRAY = new NameValuePair[0];

Review comment:
       Ok. changed 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org