From 880ee92a47796be7acf61659da571c1d70b0c9c3 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 31 Jan 2022 22:23:29 +0100 Subject: [PATCH] Drop param_id_to_hash As it turns out, it's redundant (and also had the opposite name). --- src/wrapper/vst3.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/wrapper/vst3.rs b/src/wrapper/vst3.rs index 294b10dd..771adc37 100644 --- a/src/wrapper/vst3.rs +++ b/src/wrapper/vst3.rs @@ -120,10 +120,8 @@ struct WrapperInner<'a, P: Plugin> { /// The default normalized parameter value for every parameter in `param_ids`. We need to store /// this in case the host requeries the parmaeter later. param_defaults_normalized: Vec, - /// Mappings from parameter hashes back to string parameter indentifiers. Useful for debug - /// logging and when handling plugin state. - param_id_to_hash: HashMap, - /// The inverse mapping from `param_id_hashes`. Used only for restoring state. + /// Mappings from string parameter indentifiers to parameter hashes. Useful for debug logging + /// and when storing and restorign plugin state. param_hash_to_id: HashMap<&'static str, u32>, } @@ -174,8 +172,6 @@ impl WrapperInner<'_, P> { HashMap::new(), param_defaults_normalized: Vec::new(), - param_id_to_hash: - HashMap::new(), param_hash_to_id: HashMap::new(), }; @@ -209,10 +205,6 @@ impl WrapperInner<'_, P> { .clone() .map(|(_, _, ptr)| unsafe { ptr.normalized_value() }) .collect(); - wrapper.param_id_to_hash = param_id_hashes_ptrs - .clone() - .map(|(id, hash, _)| (hash, *id)) - .collect(); wrapper.param_hash_to_id = param_id_hashes_ptrs .map(|(id, hash, _)| (*id, hash)) .collect(); @@ -499,9 +491,9 @@ impl IComponent for Wrapper<'_, P> { // We'll serialize parmaeter values as a simple `string_param_id: display_value` map. let mut params: HashMap<_, _> = self .inner - .param_id_to_hash + .param_hash_to_id .iter() - .filter_map(|(hash, param_id_str)| { + .filter_map(|(param_id_str, hash)| { let param_ptr = self.inner.param_by_hash.get(hash)?; Some((param_id_str, param_ptr)) })