From 33c2d8288b82d63273c104b80859bfa88a7566a7 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 9 Apr 2022 11:47:23 +0200 Subject: [PATCH] Don't warn on parameter hash overflow But do mention overflows in the duplicate parameter warning. --- src/wrapper/clap/wrapper.rs | 3 ++- src/wrapper/util.rs | 14 +------------- src/wrapper/vst3/inner.rs | 3 ++- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/wrapper/clap/wrapper.rs b/src/wrapper/clap/wrapper.rs index 91742b35..11e73e36 100644 --- a/src/wrapper/clap/wrapper.rs +++ b/src/wrapper/clap/wrapper.rs @@ -372,7 +372,8 @@ impl Wrapper

{ nih_debug_assert_eq!( param_map.len(), param_ids.len(), - "The plugin has duplicate parameter IDs, weird things may happen" + "The plugin has duplicate parameter IDs, weird things may happen. \ + Consider using 6 character parameter IDs to avoid collissions.." ); } diff --git a/src/wrapper/util.rs b/src/wrapper/util.rs index 8aba5a6b..58feaea5 100644 --- a/src/wrapper/util.rs +++ b/src/wrapper/util.rs @@ -10,21 +10,9 @@ static A: assert_no_alloc::AllocDisabler = assert_no_alloc::AllocDisabler; /// A Rabin fingerprint based string hash for parameter ID strings. pub fn hash_param_id(id: &str) -> u32 { - let mut overflow; - let mut overflow2; - let mut has_overflown = false; let mut hash: u32 = 0; for char in id.bytes() { - (hash, overflow) = hash.overflowing_mul(31); - (hash, overflow2) = hash.overflowing_add(char as u32); - has_overflown |= overflow || overflow2; - } - - if has_overflown { - nih_log!( - "Overflow while hashing param ID \"{}\", consider using 6 character IDs to avoid collissions", - id - ); + hash = hash.wrapping_mul(31).wrapping_add(char as u32); } // In VST3 the last bit is reserved for parameters provided by the host diff --git a/src/wrapper/vst3/inner.rs b/src/wrapper/vst3/inner.rs index 7b054613..105067f3 100644 --- a/src/wrapper/vst3/inner.rs +++ b/src/wrapper/vst3/inner.rs @@ -198,7 +198,8 @@ impl WrapperInner

{ nih_debug_assert_eq!( param_map.len(), param_ids.len(), - "The plugin has duplicate parameter IDs, weird things may happen" + "The plugin has duplicate parameter IDs, weird things may happen. \ + Consider using 6 character parameter IDs to avoid collissions.." ); let mut bypass_param_exists = false;