You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/11/20 13:19:27 UTC

[GitHub] [commons-lang] DamnedElric commented on a diff in pull request #984: Use IntStream

DamnedElric commented on code in PR #984:
URL: https://github.com/apache/commons-lang/pull/984#discussion_r1027288942


##########
src/main/java/org/apache/commons/lang3/text/StrBuilder.java:
##########
@@ -1844,12 +1845,7 @@ public StrBuilder deleteAll(final char ch) {
      * @return this, to enable chaining
      */
     public StrBuilder deleteFirst(final char ch) {
-        for (int i = 0; i < size; i++) {
-            if (buffer[i] == ch) {
-                deleteImpl(i, i + 1, 1);
-                break;
-            }
-        }
+        IntStream.range(0, size).filter(i -> buffer[i] == ch).findFirst().ifPresent(i -> deleteImpl(i, i + 1, 1));

Review Comment:
   The previous implementation was a lot easier to read and created less garbage. This one introduces a bunch of unnecessary objects at seemingly no benefit?



-- 
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: issues-unsubscribe@commons.apache.org

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