You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "divijvaidya (via GitHub)" <gi...@apache.org> on 2023/07/18 11:26:43 UTC

[GitHub] [kafka] divijvaidya commented on pull request #13627: MINOR: simplify if else conditions in Uuid.compareTo method

divijvaidya commented on PR #13627:
URL: https://github.com/apache/kafka/pull/13627#issuecomment-1640038761

   I am apprehensive about making this change. Even JDK's implementation of UUID.compareTo() uses existing code:
   ```
   @Override
       public int compareTo(UUID val) {
           // The ordering is intentionally set up so that the UUIDs
           // can simply be numerically compared as two numbers
           return (this.mostSigBits < val.mostSigBits ? -1 :
                   (this.mostSigBits > val.mostSigBits ? 1 :
                    (this.leastSigBits < val.leastSigBits ? -1 :
                     (this.leastSigBits > val.leastSigBits ? 1 :
                      0))));
       }
   ```
   
   My main concern is that the comparison is dependent on treating unsigned vs. signed values. for example, why not use Long.compareUnsigned instead of using Long.compare.
   
   I would say, it's probably safer to stick to what JDK already does.


-- 
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: jira-unsubscribe@kafka.apache.org

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