Closed fhermeni closed 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%.
Thanks Fabien !
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%.