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!
This commit is contained in:
reduz 2022-05-13 15:04:37 +02:00 committed by Rémi Verschelde
parent 396def9b66
commit 746dddc067
587 changed files with 3707 additions and 3538 deletions

View file

@ -326,8 +326,8 @@ void DisplayServerJavaScript::tts_resume() {
}
void DisplayServerJavaScript::tts_stop() {
for (Map<int, CharString>::Element *E = utterance_ids.front(); E; E = E->next()) {
tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_CANCELED, E->key());
for (const KeyValue<int, CharString> &E : utterance_ids) {
tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_CANCELED, E.key);
}
utterance_ids.clear();
godot_js_tts_stop();

View file

@ -55,7 +55,7 @@ private:
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE webgl_ctx = 0;
#endif
Map<int, CharString> utterance_ids;
HashMap<int, CharString> utterance_ids;
WindowMode window_mode = WINDOW_MODE_WINDOWED;
ObjectID window_attached_instance_id = {};

View file

@ -93,7 +93,7 @@ Error EditorExportPlatformJavaScript::_write_or_error(const uint8_t *p_content,
return OK;
}
void EditorExportPlatformJavaScript::_replace_strings(Map<String, String> p_replaces, Vector<uint8_t> &r_template) {
void EditorExportPlatformJavaScript::_replace_strings(HashMap<String, String> p_replaces, Vector<uint8_t> &r_template) {
String str_template = String::utf8(reinterpret_cast<const char *>(r_template.ptr()), r_template.size());
String out;
Vector<String> lines = str_template.split("\n");
@ -145,7 +145,7 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re
// Replaces HTML string
const String str_config = Variant(config).to_json_string();
const String custom_head_include = p_preset->get("html/head_include");
Map<String, String> replaces;
HashMap<String, String> replaces;
replaces["$GODOT_URL"] = p_name + ".js";
replaces["$GODOT_PROJECT_NAME"] = ProjectSettings::get_singleton()->get_setting("application/config/name");
replaces["$GODOT_HEAD_INCLUDE"] = head_include + custom_head_include;
@ -196,7 +196,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> &
const String dir = p_path.get_base_dir();
const String name = p_path.get_file().get_basename();
const ExportMode mode = (ExportMode)(int)p_preset->get("variant/export_type");
Map<String, String> replaces;
HashMap<String, String> replaces;
replaces["@GODOT_VERSION@"] = String::num_int64(OS::get_singleton()->get_unix_time()) + "|" + String::num_int64(OS::get_singleton()->get_ticks_usec());
replaces["@GODOT_NAME@"] = proj_name.substr(0, 16);
replaces["@GODOT_OFFLINE_PAGE@"] = name + ".offline.html";

View file

@ -104,7 +104,7 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform {
}
Error _extract_template(const String &p_template, const String &p_dir, const String &p_name, bool pwa);
void _replace_strings(Map<String, String> p_replaces, Vector<uint8_t> &r_template);
void _replace_strings(HashMap<String, String> p_replaces, Vector<uint8_t> &r_template);
void _fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector<SharedObject> p_shared_objects, const Dictionary &p_file_sizes);
Error _add_manifest_icon(const String &p_path, const String &p_icon, int p_size, Array &r_arr);
Error _build_pwa(const Ref<EditorExportPreset> &p_preset, const String p_path, const Vector<SharedObject> &p_shared_objects);
@ -138,7 +138,7 @@ public:
r_features->push_back(get_os_name().to_lower());
}
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) override {
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, RBSet<String> &p_features) override {
}
String get_debug_protocol() const override { return "ws://"; }

View file

@ -41,7 +41,7 @@
class EditorHTTPServer : public RefCounted {
private:
Ref<TCPServer> server;
Map<String, String> mimes;
HashMap<String, String> mimes;
Ref<StreamPeerTCP> tcp;
Ref<StreamPeerSSL> ssl;
Ref<StreamPeer> peer;