Don't warn on parameter hash overflow
But do mention overflows in the duplicate parameter warning.
This commit is contained in:
parent
f0303fed4b
commit
33c2d8288b
3 changed files with 5 additions and 15 deletions
|
@ -372,7 +372,8 @@ impl<P: ClapPlugin> Wrapper<P> {
|
||||||
nih_debug_assert_eq!(
|
nih_debug_assert_eq!(
|
||||||
param_map.len(),
|
param_map.len(),
|
||||||
param_ids.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.."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,21 +10,9 @@ static A: assert_no_alloc::AllocDisabler = assert_no_alloc::AllocDisabler;
|
||||||
|
|
||||||
/// A Rabin fingerprint based string hash for parameter ID strings.
|
/// A Rabin fingerprint based string hash for parameter ID strings.
|
||||||
pub fn hash_param_id(id: &str) -> u32 {
|
pub fn hash_param_id(id: &str) -> u32 {
|
||||||
let mut overflow;
|
|
||||||
let mut overflow2;
|
|
||||||
let mut has_overflown = false;
|
|
||||||
let mut hash: u32 = 0;
|
let mut hash: u32 = 0;
|
||||||
for char in id.bytes() {
|
for char in id.bytes() {
|
||||||
(hash, overflow) = hash.overflowing_mul(31);
|
hash = hash.wrapping_mul(31).wrapping_add(char as u32);
|
||||||
(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
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// In VST3 the last bit is reserved for parameters provided by the host
|
// In VST3 the last bit is reserved for parameters provided by the host
|
||||||
|
|
|
@ -198,7 +198,8 @@ impl<P: Vst3Plugin> WrapperInner<P> {
|
||||||
nih_debug_assert_eq!(
|
nih_debug_assert_eq!(
|
||||||
param_map.len(),
|
param_map.len(),
|
||||||
param_ids.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;
|
let mut bypass_param_exists = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue