RFR: 8366238: Improve RBTree API with stricter comparator semantics and pluggable validation/printing hooks. [v2]

Casper Norrbin cnorrbin at openjdk.org
Thu Aug 28 11:34:43 UTC 2025


On Thu, 28 Aug 2025 10:32:41 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

>> Casper Norrbin has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   renamed less to less_than
>
> I noticed that in one place
> 
> 
> (parent_cmp <= 0 && hint_cmp < 0)
> 
> becomes
> 
> (parent_cmp != RBTreeOrdering::greater && hint_cmp == RBTreeOrdering::less)
> 
> 
> I wonder if compare-result can have some helper apis so that the new code looks like
> 
> (parent_cmp.is_less_equal() && hint_cmp.is_less())
> 
> 
> Can't say for sure one is definitely better than the other; just throwing out some ideas.

Thank you for the review @albertnetymk.
> I wonder if compare-result can have some helper apis so that the new code looks like
> 
> ```
> (parent_cmp.is_less_equal() && hint_cmp.is_less())
> ```

Unfortunately, we can't add helpers directly to the `enum class`, so we'd have to either
1. Wrap it in another struct or class, or
2. Add a separate set of functions (e.g. `is_less(order)` or `is_less_equal(order)`)

Either option introduces extra code for something that's only used internally in the tree in a couple of places. For now, the explicit comparisons is (to me) readable enough, so I'd prefer to keep it as is.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/26981#issuecomment-3233127699


More information about the hotspot-dev mailing list