Skip to content

Commit 8e337b3

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Add Allocative
Reviewed By: ndmitchell Differential Revision: D41036062 fbshipit-source-id: ac8060f04a9ce0c39616c928711de0991c424018
1 parent abbde18 commit 8e337b3

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

starlark_map/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ gazebo.features = ["str_pattern_extensions"]
1717
gazebo_lint.version = "0.1"
1818
gazebo_lint.optional = true
1919
# @oss-disable: gazebo_lint.path = "../../gazebo_lint/gazebo_lint"
20+
allocative.version = "0.2"
21+
# @oss-disable: allocative.path = "../../allocative/allocative"
22+
allocative.features = ["hashbrown"]
2023

2124
fnv = "1.0.7"
2225
hashbrown = { version = "0.12.3", features = ["raw"] }

starlark_map/src/hash_value.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
use std::fmt::Debug;
1919
use std::hash::Hash;
2020

21+
use allocative::Allocative;
2122
use gazebo::dupe::Dupe;
2223

2324
use crate::hasher::StarlarkHasher;
2425
use crate::mix_u32::mix_u32;
2526

2627
/// A hash value.
27-
#[derive(Clone, Copy, Dupe, PartialEq, Eq, Hash, Debug)]
28+
#[derive(Clone, Copy, Dupe, PartialEq, Eq, Hash, Debug, Allocative)]
2829
pub struct StarlarkHashValue(u32);
2930

3031
impl StarlarkHashValue {

starlark_map/src/hashed.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ use std::hash::Hash;
2121
use std::hash::Hasher;
2222
use std::ops::Deref;
2323

24+
use allocative::Allocative;
2425
use gazebo::prelude::Dupe;
2526

2627
use crate::equivalent::Equivalent;
2728
use crate::hash_value::StarlarkHashValue;
2829

2930
/// A key and its hash.
30-
#[derive(PartialEq, Eq, Debug, Clone, Copy, Dupe)]
31+
#[derive(PartialEq, Eq, Debug, Clone, Copy, Dupe, Allocative)]
3132
pub struct Hashed<K> {
3233
hash: StarlarkHashValue,
3334
key: K,

starlark_map/src/small_map/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use std::hash::Hash;
2626
use std::hash::Hasher;
2727
use std::mem;
2828

29+
use allocative::Allocative;
2930
use gazebo::coerce::Coerce;
3031
use gazebo::coerce::CoerceKey;
3132
use gazebo::prelude::*;
@@ -58,7 +59,7 @@ const NO_INDEX_THRESHOLD: usize = 12;
5859
///
5960
/// * Functions which work with the position, e.g. [`get_index_of`](SmallMap::get_index_of).
6061
#[repr(C)]
61-
#[derive(Clone, Default_)]
62+
#[derive(Clone, Default_, Allocative)]
6263
pub struct SmallMap<K, V> {
6364
entries: VecMap<K, V>,
6465
/// Map a key to the index in `entries`.

starlark_map/src/small_set/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use std::fmt::Debug;
2222
use std::hash::Hash;
2323
use std::hash::Hasher;
2424

25+
use allocative::Allocative;
2526
use gazebo::prelude::*;
2627

2728
use crate::equivalent::Equivalent;
@@ -31,7 +32,7 @@ pub use crate::small_set::iter::IntoIter;
3132
pub use crate::small_set::iter::Iter;
3233

3334
/// An memory-efficient set with determinstic order, based on [`SmallMap`].
34-
#[derive(Clone, Default_)]
35+
#[derive(Clone, Default_, Allocative)]
3536
pub struct SmallSet<T>(SmallMap<T, ()>);
3637

3738
impl<T: Debug> Debug for SmallSet<T> {

starlark_map/src/vec_map/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use std::hash::Hash;
2121
use std::hash::Hasher;
2222
use std::mem;
2323

24+
use allocative::Allocative;
2425
use gazebo::prelude::*;
2526

2627
use crate::equivalent::Equivalent;
@@ -36,7 +37,7 @@ pub(crate) use crate::vec_map::iter::Values;
3637
pub(crate) use crate::vec_map::iter::ValuesMut;
3738

3839
/// Bucket in [`VecMap`].
39-
#[derive(Debug, Clone, Eq, PartialEq)]
40+
#[derive(Debug, Clone, Eq, PartialEq, Allocative)]
4041
pub(crate) struct Bucket<K, V> {
4142
hash: StarlarkHashValue,
4243
key: K,
@@ -53,7 +54,7 @@ impl<K: Hash, V: Hash> Hash for Bucket<K, V> {
5354
}
5455
}
5556

56-
#[derive(Debug, Clone, Eq, PartialEq, Default_)]
57+
#[derive(Debug, Clone, Eq, PartialEq, Default_, Allocative)]
5758
pub(crate) struct VecMap<K, V> {
5859
buckets: Vec<Bucket<K, V>>,
5960
}

0 commit comments

Comments
 (0)