From 746dddc0673d7261f19b1e056e90e6e3a49ef33a Mon Sep 17 00:00:00 2001 From: reduz Date: Fri, 13 May 2022 15:04:37 +0200 Subject: Replace most uses of Map by HashMap * Map is unnecessary and inefficient in almost every case. * Replaced by the new HashMap. * Renamed Map to RBMap and Set to RBSet for cases that still make sense (order matters) but use is discouraged. There were very few cases where replacing by HashMap was undesired because keeping the key order was intended. I tried to keep those (as RBMap) as much as possible, but might have missed some. Review appreciated! --- servers/audio/audio_stream.h | 4 ++-- servers/audio/effects/audio_effect_eq.cpp | 8 ++++---- servers/audio/effects/audio_effect_eq.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'servers/audio') diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h index 9800707849..8851e1419b 100644 --- a/servers/audio/audio_stream.h +++ b/servers/audio/audio_stream.h @@ -125,7 +125,7 @@ class AudioStreamMicrophone : public AudioStream { GDCLASS(AudioStreamMicrophone, AudioStream); friend class AudioStreamPlaybackMicrophone; - Set playbacks; + RBSet playbacks; protected: static void _bind_methods(); @@ -192,7 +192,7 @@ private: float weight; }; - Set playbacks; + RBSet playbacks; Vector audio_stream_pool; float random_pitch_scale = 1.1f; float random_volume_offset_db = 5.0f; diff --git a/servers/audio/effects/audio_effect_eq.cpp b/servers/audio/effects/audio_effect_eq.cpp index cc317031d4..b7c373479a 100644 --- a/servers/audio/effects/audio_effect_eq.cpp +++ b/servers/audio/effects/audio_effect_eq.cpp @@ -90,9 +90,9 @@ int AudioEffectEQ::get_band_count() const { } bool AudioEffectEQ::_set(const StringName &p_name, const Variant &p_value) { - const Map::Element *E = prop_band_map.find(p_name); + HashMap::ConstIterator E = prop_band_map.find(p_name); if (E) { - set_band_gain_db(E->get(), p_value); + set_band_gain_db(E->value, p_value); return true; } @@ -100,9 +100,9 @@ bool AudioEffectEQ::_set(const StringName &p_name, const Variant &p_value) { } bool AudioEffectEQ::_get(const StringName &p_name, Variant &r_ret) const { - const Map::Element *E = prop_band_map.find(p_name); + HashMap::ConstIterator E = prop_band_map.find(p_name); if (E) { - r_ret = get_band_gain_db(E->get()); + r_ret = get_band_gain_db(E->value); return true; } diff --git a/servers/audio/effects/audio_effect_eq.h b/servers/audio/effects/audio_effect_eq.h index 252f931e6c..9b0560223f 100644 --- a/servers/audio/effects/audio_effect_eq.h +++ b/servers/audio/effects/audio_effect_eq.h @@ -55,7 +55,7 @@ class AudioEffectEQ : public AudioEffect { EQ eq; Vector gain; - Map prop_band_map; + HashMap prop_band_map; Vector band_names; protected: -- cgit v1.2.3