mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-11 06:19:41 +00:00
e63f66826d
This change allows us to avoid O(n^2) performance when partially sorted data is given to NS_QuickSort. We no longer attempt an insertion sort if the input appears pre-sorted. This brings the expected performance back to O(n*log(n)) but also eliminates the possibility of O(n) best case performance. Attempts to achieve O(n) performance should be the responsibility of callers as they are in a better position to evaluate the costs/benefit trade-off of looking for special cases that can be sorted quicker.