about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-24 08:12:56 +0200
committerGitHub <noreply@github.com>2025-04-24 08:12:56 +0200
commitcb3c5d773ce76e3fa869402db87429bed637cc54 (patch)
tree12ba63d71709ed916473963201a460d9b7b75040
parentfdaa91a0d7a1339187a80bc837770f4851d99e39 (diff)
parent16381b3133c2ab6da503d7680700fe63705636b5 (diff)
downloadrust-cb3c5d773ce76e3fa869402db87429bed637cc54.tar.gz
rust-cb3c5d773ce76e3fa869402db87429bed637cc54.zip
Rollup merge of #139307 - xizheyin:issue-139296, r=joboet
std: Add performance warnings to HashMap::get_disjoint_mut

Closes #139296

The `get_disjoint_mut` in `HashMap` also performs a complexity O(n^2) check. So we need to be reminded of that as well.

https://github.com/rust-lang/hashbrown/blob/b5b0655a37e156f9798ac8dd7e970d4adba9bf90/src/raw/mod.rs#L1216-L1220
-rw-r--r--library/std/src/collections/hash/map.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs
index 0eef2bd225c..9ad26e5d28e 100644
--- a/library/std/src/collections/hash/map.rs
+++ b/library/std/src/collections/hash/map.rs
@@ -973,6 +973,9 @@ where
     /// Returns an array of length `N` with the results of each query. For soundness, at most one
     /// mutable reference will be returned to any value. `None` will be used if the key is missing.
     ///
+    /// This method performs a check to ensure there are no duplicate keys, which currently has a time-complexity of O(n^2),
+    /// so be careful when passing many keys.
+    ///
     /// # Panics
     ///
     /// Panics if any keys are overlapping.