You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2022/09/30 20:35:20 UTC

[GitHub] [cxf] knut-estalea opened a new pull request, #1003: Fix SortedArraySet remove, containsAll

knut-estalea opened a new pull request, #1003:
URL: https://github.com/apache/cxf/pull/1003

   Remove would fail when removing the not-lowest entry.
   The implementation of `containsAll` was "containsAny".
   Also tweaks `add` to use binary search + insert instead
   of a full sort every time.


-- 
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: dev-unsubscribe@cxf.apache.org

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


[GitHub] [cxf] reta commented on a diff in pull request #1003: Fix SortedArraySet remove, containsAll

Posted by GitBox <gi...@apache.org>.
reta commented on code in PR #1003:
URL: https://github.com/apache/cxf/pull/1003#discussion_r985260354


##########
core/src/main/java/org/apache/cxf/common/util/SortedArraySet.java:
##########
@@ -138,20 +142,21 @@ public boolean remove(Object o) {
             return false;
         }
         int idx = Arrays.binarySearch(tmp, o);
-        if (idx != -1) {

Review Comment:
   👍 



##########
core/src/main/java/org/apache/cxf/common/util/SortedArraySet.java:
##########
@@ -99,9 +103,9 @@ public boolean addAll(Collection<? extends T> c) {
         return val;
     }
     public boolean containsAll(Collection<?> c) {

Review Comment:
   We probably could make it even better by returning as early as possible (upon finding first non-containing element)?



##########
core/src/main/java/org/apache/cxf/common/util/SortedArraySet.java:
##########
@@ -71,25 +71,29 @@ private T[] newArray(int size) {
     }
 
     public boolean add(T o) {

Review Comment:
   👍 



##########
core/src/main/java/org/apache/cxf/common/util/SortedArraySet.java:
##########
@@ -99,9 +103,9 @@ public boolean addAll(Collection<? extends T> c) {
         return val;
     }
     public boolean containsAll(Collection<?> c) {

Review Comment:
   Since class is public, it could be used outside of CXF codebase ...



-- 
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: dev-unsubscribe@cxf.apache.org

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


[GitHub] [cxf] knut-estalea commented on a diff in pull request #1003: Fix SortedArraySet remove, containsAll

Posted by GitBox <gi...@apache.org>.
knut-estalea commented on code in PR #1003:
URL: https://github.com/apache/cxf/pull/1003#discussion_r984932840


##########
core/src/main/java/org/apache/cxf/common/util/SortedArraySet.java:
##########
@@ -71,25 +71,29 @@ private T[] newArray(int size) {
     }
 
     public boolean add(T o) {

Review Comment:
   The changes to `add` aren't fixing any bug. It just seemed like a waste to do a full sort every time.



##########
core/src/main/java/org/apache/cxf/common/util/SortedArraySet.java:
##########
@@ -138,20 +142,21 @@ public boolean remove(Object o) {
             return false;
         }
         int idx = Arrays.binarySearch(tmp, o);
-        if (idx != -1) {

Review Comment:
   The bug was here (idx == -1). Every negative value means "not found".



##########
core/src/main/java/org/apache/cxf/common/util/SortedArraySet.java:
##########
@@ -99,9 +103,9 @@ public boolean addAll(Collection<? extends T> c) {
         return val;
     }
     public boolean containsAll(Collection<?> c) {

Review Comment:
   This method is unused in the CXF code base as far as I can tell.



-- 
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: dev-unsubscribe@cxf.apache.org

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