mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 04:24:33 +01:00
PR #20927 made some improvements to the `binarySearch` API, but one change I found surprising was the relationship between the left-hand and right-hand parameters of `compareFn` was inverted. This is different from how comparison functions typically behave, both in other parts of Zig (e.g. `std.math.order`) and in other languages (e.g. C's `bsearch`). Unless a strong reason can be identified and documented for doing otherwise, I think it'll be better to stick with convention. While writing this patch and changing things back to the way they were, the predicates of `lowerBound` and `upperBound` seemed to be the only areas that benefited from the inversion. I don't think that benefit is worth the cost, personally. Calling `Order.invert()` in the predicates accomplishes the same goal. |
||
|---|---|---|
| .. | ||
| compiler | ||
| compiler_rt | ||
| docs | ||
| fuzzer/web | ||
| include | ||
| init | ||
| libc | ||
| libcxx | ||
| libcxxabi | ||
| libunwind | ||
| std | ||
| tsan | ||
| c.zig | ||
| compiler_rt.zig | ||
| fuzzer.zig | ||
| zig.h | ||