Skip to content

Commit 2289dce

Browse files
committed
Restrict nohash visibility explicitly
Signed-off-by: Liam Gray <[email protected]>
1 parent 56e7e60 commit 2289dce

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

benches/counter.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// limitations under the License.
1313

1414
use criterion::{black_box, criterion_group, criterion_main, Criterion};
15-
use prometheus::{Counter, CounterVec, IntCounter, Opts};
1615
use fnv::FnvBuildHasher;
16+
use prometheus::{Counter, CounterVec, IntCounter, Opts};
1717
use std::collections::HashMap;
1818
use std::sync::{atomic, Arc};
1919
use std::thread;
@@ -25,7 +25,11 @@ fn bench_counter_with_label_values(c: &mut Criterion) {
2525
)
2626
.unwrap();
2727
c.bench_function("counter_with_label_values", |b| {
28-
b.iter(|| counter.with_label_values(&black_box(["eins", "zwei", "drei"])).inc())
28+
b.iter(|| {
29+
counter
30+
.with_label_values(&black_box(["eins", "zwei", "drei"]))
31+
.inc()
32+
})
2933
});
3034
}
3135

@@ -52,7 +56,7 @@ fn bench_counter_with_mapped_labels_fnv(c: &mut Criterion) {
5256
Opts::new("benchmark_counter", "A counter to benchmark it."),
5357
&["one", "two", "three"],
5458
)
55-
.unwrap();
59+
.unwrap();
5660

5761
c.bench_function("counter_with_mapped_labels_fnv", |b| {
5862
b.iter(|| {

src/nohash.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use std::hash::{BuildHasherDefault, Hasher};
22

33
/// Inspired by nohash-hasher, but we avoid the crate dependency because it's in public archive.
44
#[derive(Copy, Clone, Debug, Default)]
5-
pub struct NoHashHasher(u64);
5+
pub(crate) struct NoHashHasher(u64);
66

7-
pub type BuildNoHashHasher = BuildHasherDefault<NoHashHasher>;
7+
pub(crate) type BuildNoHashHasher = BuildHasherDefault<NoHashHasher>;
88

99
impl Hasher for NoHashHasher {
1010
#[inline]

src/vec.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ impl<T: MetricVecBuilder> MetricVecCore<T> {
157157
Ok(h.finish())
158158
}
159159

160-
fn get_label_values<'a, V, S: BuildHasher>(&'a self, labels: &'a HashMap<&str, V, S>) -> Result<Vec<&'a str>>
160+
fn get_label_values<'a, V, S: BuildHasher>(
161+
&'a self,
162+
labels: &'a HashMap<&str, V, S>,
163+
) -> Result<Vec<&'a str>>
161164
where
162165
V: AsRef<str> + std::fmt::Debug,
163166
{

0 commit comments

Comments
 (0)