Skip to content

Commit 7c6986a

Browse files
stepanchegfacebook-github-bot
authored andcommitted
get_index_of_hashed_raw_with_index
Summary: `RawTable::get` function is relatively large, and it is often inlined into `get_index_of_hashed_raw`. So `get_index_of_hashed_raw` is never inlined. So the simple path of searching in `VecMap` is always behind a call. When `get_index_of_hashed_raw_with_index` extracted, `RawTable::get` is inlined into `get_index_of_hashed_raw_with_index`, which is not inlined, but `get_index_of_hashed_raw` is now often inlined, so code path without index does not have calls. Reviewed By: ndmitchell Differential Revision: D40913232 fbshipit-source-id: 33e193ee562562a73776cbf849dfb6ce29578490
1 parent 34ebdc0 commit 7c6986a

File tree

1 file changed

+16
-6
lines changed
  • starlark_map/src/small_map

1 file changed

+16
-6
lines changed

starlark_map/src/small_map/mod.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,28 @@ impl<K, V> SmallMap<K, V> {
261261
}
262262

263263
#[inline]
264-
pub(crate) fn get_index_of_hashed_raw(
264+
fn get_index_of_hashed_raw_with_index(
265265
&self,
266266
hash: StarlarkHashValue,
267267
mut eq: impl FnMut(&K) -> bool,
268+
index: &RawTable<usize>,
269+
) -> Option<usize> {
270+
index
271+
.get(hash.promote(), |&index| unsafe {
272+
eq(self.entries.get_unchecked(index).0.key())
273+
})
274+
.copied()
275+
}
276+
277+
#[inline]
278+
pub(crate) fn get_index_of_hashed_raw(
279+
&self,
280+
hash: StarlarkHashValue,
281+
eq: impl FnMut(&K) -> bool,
268282
) -> Option<usize> {
269283
match &self.index {
270284
None => self.entries.get_index_of_hashed_raw(hash, eq),
271-
Some(index) => index
272-
.get(hash.promote(), |&index| unsafe {
273-
eq(self.entries.get_unchecked(index).0.key())
274-
})
275-
.copied(),
285+
Some(index) => self.get_index_of_hashed_raw_with_index(hash, eq, index),
276286
}
277287
}
278288

0 commit comments

Comments
 (0)