From 4e15be182e27c1a0166a5df451ddfbc248247d96 Mon Sep 17 00:00:00 2001 From: Langston Barrett Date: Mon, 6 Feb 2023 09:50:26 -0500 Subject: [PATCH] Increase default initial capacity of NewHashFeedback (#1049) --- libafl/src/feedbacks/new_hash_feedback.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libafl/src/feedbacks/new_hash_feedback.rs b/libafl/src/feedbacks/new_hash_feedback.rs index 0b74cc49fa..1278201170 100644 --- a/libafl/src/feedbacks/new_hash_feedback.rs +++ b/libafl/src/feedbacks/new_hash_feedback.rs @@ -148,6 +148,12 @@ impl HasObserverName for NewHashFeedback { } } +/// Default capacity for the [`HashSet`] in [`NewHashFeedback`]. +/// +/// This is reasonably large on the assumption that you expect there to be many +/// runs of the target, producing many different feedbacks. +const DEFAULT_CAPACITY: usize = 4096; + impl NewHashFeedback where O: ObserverWithHashField + Named + Debug, @@ -159,7 +165,7 @@ where Self { name: name.to_string(), observer_name: observer_name.to_string(), - capacity: 0, + capacity: DEFAULT_CAPACITY, o_type: PhantomData, } } @@ -167,7 +173,7 @@ where /// Returns a new [`NewHashFeedback`]. #[must_use] pub fn new(observer: &O) -> Self { - Self::with_capacity(observer, 0) + Self::with_capacity(observer, DEFAULT_CAPACITY) } /// Returns a new [`NewHashFeedback`] that will create a hash set with the