Metadata lookup once (#186)

* metadata lookup once

* fix clippy
This commit is contained in:
Dominik Maier 2021-06-22 18:41:46 +02:00 committed by GitHub
parent bdb5efbf5b
commit 37f641f79b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -7,7 +7,7 @@ use core::any::{Any, TypeId};
// yolo
/// Get a `type_id` from it's previously unpacked `u64`.
/// Get a `type_id` from its previously unpacked `u64`.
/// Opposite of [`unpack_type_id(id)`].
///
/// # Safety

View File

@ -113,10 +113,13 @@ where
where
S: HasMetadata,
{
if state.metadata().get::<CmpValuesMetadata>().is_none() {
#[allow(clippy::clippy::option_if_let_else)] // we can't mutate state in a closure
let meta = if let Some(meta) = state.metadata_mut().get_mut::<CmpValuesMetadata>() {
meta
} else {
state.add_metadata(CmpValuesMetadata::new());
}
let meta = state.metadata_mut().get_mut::<CmpValuesMetadata>().unwrap();
state.metadata_mut().get_mut::<CmpValuesMetadata>().unwrap()
};
meta.list.clear();
let count = self.usable_count();
for i in 0..count {