Skip to content

Commit 37f641f

Browse files
authored
Metadata lookup once (#186)
* metadata lookup once * fix clippy
1 parent bdb5efb commit 37f641f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

libafl/src/bolts/serdeany.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::any::{Any, TypeId};
77

88
// yolo
99

10-
/// Get a `type_id` from it's previously unpacked `u64`.
10+
/// Get a `type_id` from its previously unpacked `u64`.
1111
/// Opposite of [`unpack_type_id(id)`].
1212
///
1313
/// # Safety

libafl/src/observers/cmp.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,13 @@ where
113113
where
114114
S: HasMetadata,
115115
{
116-
if state.metadata().get::<CmpValuesMetadata>().is_none() {
116+
#[allow(clippy::clippy::option_if_let_else)] // we can't mutate state in a closure
117+
let meta = if let Some(meta) = state.metadata_mut().get_mut::<CmpValuesMetadata>() {
118+
meta
119+
} else {
117120
state.add_metadata(CmpValuesMetadata::new());
118-
}
119-
let meta = state.metadata_mut().get_mut::<CmpValuesMetadata>().unwrap();
121+
state.metadata_mut().get_mut::<CmpValuesMetadata>().unwrap()
122+
};
120123
meta.list.clear();
121124
let count = self.usable_count();
122125
for i in 0..count {

0 commit comments

Comments
 (0)