chocoteam / choco-solver

An open-source Java library for Constraint Programming
http://choco-solver.org/
BSD 4-Clause "Original" or "Old" License
690 stars 143 forks source link

Improve PropNValue.contains(). #1052

Closed fhermeni closed 1 year ago

fhermeni commented 1 year ago

This used to run in O(n). Given the array is read-only, it is ok to sort it and use Arrays.binarySearch() to perform in O(log(n)).

For an internal benchmark with 128 values to watch, contains() was the bottleneck (5% of the service latency), now it is < 1%.

jgFages commented 1 year ago

Thanks Fabien !