carterkozak commented on a change in pull request #326:
URL: 
https://github.com/apache/httpcomponents-client/pull/326#discussion_r750516739



##########
File path: 
httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpByteArrayCacheEntrySerializerTestUtils.java
##########
@@ -320,9 +321,7 @@ private static int readFully(final InputStream src, final 
byte[] dest) throws IO
      *                     number of bytes have been read
      */
     static byte[] readFullyStrict(final InputStream src, final long length) 
throws IOException {
-        if (length > Integer.MAX_VALUE) {
-            throw new IllegalArgumentException(String.format("Length %d is too 
large to fit in an array", length));
-        }
+        Args.check(length <= Integer.MAX_VALUE, String.format("Length %d is 
too large to fit in an array", length));

Review comment:
       Boxing + varargs allocation isn't ideal, but it beats string allocation 
and string.format.
   Lambda allocation can take a while to optimize away depending on the jvm, 
especially since it's not static -- the length value must be captured from the 
call-site. Still beats String.format though.
   
   It's hard to beat a conditional :-)




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to