about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/vec_cache.rs
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@users.noreply.github.com>2025-02-10 06:07:06 +0000
committerGitHub <noreply@github.com>2025-02-10 06:07:06 +0000
commit8fd713b7d3bc773b0911518c4e4ee7f1ac284220 (patch)
tree1aa51f29a63a69ab827eb37366f0bcaada3da97e /compiler/rustc_data_structures/src/vec_cache.rs
parentd4f7c7668fece15523ae6f38e437cad01ee5ded6 (diff)
parent24d7a1490a8193350b006b7a5f71edd97a63afd1 (diff)
downloadrust-8fd713b7d3bc773b0911518c4e4ee7f1ac284220.tar.gz
rust-8fd713b7d3bc773b0911518c4e4ee7f1ac284220.zip
Merge pull request #19126 from lnicola/sync-from-rust
minor: Sync from downstream
Diffstat (limited to 'compiler/rustc_data_structures/src/vec_cache.rs')
-rw-r--r--compiler/rustc_data_structures/src/vec_cache.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/vec_cache.rs b/compiler/rustc_data_structures/src/vec_cache.rs
index eb251b587c8..2ff60ab7f36 100644
--- a/compiler/rustc_data_structures/src/vec_cache.rs
+++ b/compiler/rustc_data_structures/src/vec_cache.rs
@@ -206,6 +206,19 @@ impl SlotIndex {
     }
 }
 
+/// In-memory cache for queries whose keys are densely-numbered IDs
+/// (e.g `CrateNum`, `LocalDefId`), and can therefore be used as indices
+/// into a dense vector of cached values.
+///
+/// (As of [#124780] the underlying storage is not an actual `Vec`, but rather
+/// a series of increasingly-large buckets, for improved performance when the
+/// parallel frontend is using multiple threads.)
+///
+/// Each entry in the cache stores the query's return value (`V`), and also
+/// an associated index (`I`), which in practice is a `DepNodeIndex` used for
+/// query dependency tracking.
+///
+/// [#124780]: https://github.com/rust-lang/rust/pull/124780
 pub struct VecCache<K: Idx, V, I> {
     // Entries per bucket:
     // Bucket  0:       4096 2^12