rust/compiler/rustc_data_structures/src
bors 25f8d01fd8 Auto merge of #114231 - ttsugriy:binary_search_slice, r=cjgillot
[rustc_data_structures] Use partition_point to find  slice range end.

This PR uses approach introduced in https://github.com/rust-lang/rust/pull/114152 to find
the end of the range. It's much easier to understand and reason about invariants of such
implementation.
Technically it's possible to make it even shorter by returning `&[start..end]` unconditionally
because even if searched item is not present in the slice, `start` and `end` would point at
the same index, so the range would be empty. The reason I decided not to use this shorter
implementation is because it would involve more comparisons in case there are no elements
in the slice with key equal to `key`.

Also, not that it matters much, but this implementation also improves perf according to the
benchmark below:
https://gist.github.com/ttsugriy/63c0ed39ae132b131931fa1f8a3dea55

The results on my M1 macbook air are:
```
Running benches/bin_search_slice_benchmark.rs (target/release/deps/bin_search_slice_benchmark-90fa6d68c3bd1298)
Benchmarking multiply add/binary_search_slice: Collecting 100 samples in estimated 5.0002 s (1
multiply add/binary_search_slice
                        time:   [44.719 ns 44.918 ns 45.158 ns]
                        No change in performance detected.
Found 3 outliers among 100 measurements (3.00%)
  1 (1.00%) high mild
  2 (2.00%) high severe
Benchmarking multiply add/binary_search_slice_new: Collecting 100 samples in estimated 5.0001
multiply add/binary_search_slice_new
                        time:   [36.955 ns 37.060 ns 37.221 ns]
                        No change in performance detected.
Found 7 outliers among 100 measurements (7.00%)
  3 (3.00%) high mild
  4 (4.00%) high severe
```
2024-01-18 18:54:54 +00:00
..
base_n Adapt rustc_data_structures tests to run in strict miri 2022-06-04 17:46:29 +02:00
binary_search_util Remove invariant comments 2023-11-05 17:35:37 -06:00
fingerprint remove redundant imports 2023-12-10 10:56:22 +08:00
flock added support for GNU/Hurd 2023-09-21 17:31:25 +02:00
graph Inline dominator check. 2023-12-31 00:37:45 +00:00
intern remove redundant imports 2023-12-10 10:56:22 +08:00
obligation_forest remove redundant imports 2023-12-10 10:56:22 +08:00
owned_slice Don't leak the function that is called on drop 2023-05-23 14:53:36 +00:00
profiling Don't use serde_json to serialize a simple JSON object 2023-04-16 15:00:06 +02:00
sip128 remove redundant imports 2023-12-10 10:56:22 +08:00
small_c_str mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
snapshot_map Call the method fork instead of clone and add proper comments 2022-02-14 12:57:20 -03:00
sorted_map Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
sso more clippy::style fixes: 2023-07-23 23:39:04 +02:00
stable_hasher Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
sync Enforce NonZeroUsize on thread count 2023-11-23 20:10:44 -05:00
tagged_ptr update cfg(bootstrap)s 2023-12-22 11:14:11 +01:00
tiny_list rustc_data_structures: remove ref patterns and other artifacts of the past 2023-01-17 07:48:19 +00:00
transitive_relation get rid of RefCell in TransitiveRelation 2022-08-22 18:08:46 +08:00
aligned.rs fix broken intradoclinks 2023-04-14 13:04:58 +00:00
atomic_ref.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
base_n.rs [rustc_data_structures][base_n][perf] Remove unnecessary utf8 check. 2023-08-01 11:10:17 -07:00
captures.rs Remove #[allow(unused_lifetimes)] which is now unnecessary 2021-06-17 08:56:54 +09:00
fingerprint.rs Use the full Fingerprint when stringifying Svh 2023-04-30 14:28:30 -04:00
flat_map_in_place.rs Rename MapInPlace as FlatMapInPlace. 2023-03-08 15:53:56 +11:00
flock.rs Initiate the inner usage of cfg_match 2023-10-19 20:18:51 -03:00
frozen.rs Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
fx.rs rustc_mir_transform: Make DestinationPropagation stable for queries 2024-01-05 20:55:32 +01:00
hashes.rs Do not store stable crate id in on-disk hash map. 2023-12-24 17:22:48 +00:00
intern.rs Don't print Interned or PrivateZst 2023-06-09 00:20:37 +00:00
jobserver.rs 1. fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before use 2023-12-08 09:50:28 +08:00
lib.rs Update to bitflags 2 in the compiler 2023-12-30 18:17:28 +01:00
macros.rs Introduce ChunkedBitSet and use it for some dataflow analyses. 2022-02-23 10:18:49 +11:00
marker.rs use portable AtomicU64 for powerPC and MIPS 2023-11-06 09:58:51 +08:00
memmap.rs elaborate a bit on the (lack of) safety in 'Mmap::map' 2023-08-19 12:50:26 +02:00
owned_slice.rs Fixup comments 2023-05-16 12:09:24 +00:00
profiling.rs Update to bitflags 2 in the compiler 2023-12-30 18:17:28 +01:00
sharded.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
sip128.rs deny(unsafe_op_in_unsafe_fn) in rustc_data_structures 2023-04-19 18:00:48 +00:00
small_c_str.rs Add OwnedTargetMachine to manage llvm:TargetMachine. Uses pointers 2023-09-24 21:11:37 +02:00
sorted_map.rs Avoid specialization for the Span Encodable and Decodable impls 2023-12-31 20:42:17 +00:00
stable_hasher.rs Split StableCompare trait out of StableOrd trait. 2024-01-04 13:32:42 +01:00
stack.rs Fix some clippy::complexity 2023-04-09 23:22:14 +02:00
steal.rs Harden the pre-tyctxt query system against accidental recomputation 2023-01-12 09:26:28 +00:00
svh.rs Avoid specialization for the Span Encodable and Decodable impls 2023-12-31 20:42:17 +00:00
sync.rs don't reexport atomic::ordering via rustc_data_structures, use std import 2024-01-06 15:01:10 +03:00
tagged_ptr.rs Simplify bits_for_tags impl 2023-04-20 19:54:10 +00:00
temp_dir.rs Update dependencies with reported vulnerabilities 2023-06-02 12:34:01 -05:00
tiny_list.rs rustc_data_structures: remove ref patterns and other artifacts of the past 2023-01-17 07:48:19 +00:00
transitive_relation.rs Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
unhash.rs Avoid rehashing Fingerprint as a map key 2020-09-01 18:27:02 -07:00
unord.rs Auto merge of #119478 - bjorn3:no_serialize_specialization, r=wesleywiser 2024-01-06 09:56:00 +00:00
vec_linked_list.rs Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
work_queue.rs Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00