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/10/31 15:55:14 UTC

[GitHub] [commons-text] arturobernalg commented on a diff in pull request #375: Use java8 Stream.

arturobernalg commented on code in PR #375:
URL: https://github.com/apache/commons-text/pull/375#discussion_r1009584981


##########
src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java:
##########
@@ -125,12 +125,7 @@ int uniqueElementSize() {
      * @return The intersection
      */
     private static <T> int getIntersection(final Set<T> setA, final Set<T> setB) {
-        int intersection = 0;
-        for (final T element : setA) {
-            if (setB.contains(element)) {
-                intersection++;
-            }
-        }
+        int intersection = (int) setA.stream().filter(setB::contains).count();

Review Comment:
   inline.
   meanwhile I have change your remarks.



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