From 0c418dce4d9d9cf44dbdbde16396c3f7a05de083 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 23 Jan 2023 15:02:44 -0700 Subject: [PATCH] Use `std::unordered_map` --- src/SFML/Window/Unix/KeyboardImpl.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/SFML/Window/Unix/KeyboardImpl.cpp b/src/SFML/Window/Unix/KeyboardImpl.cpp index f6e71d47..aaac56e4 100644 --- a/src/SFML/Window/Unix/KeyboardImpl.cpp +++ b/src/SFML/Window/Unix/KeyboardImpl.cpp @@ -37,8 +37,8 @@ #include #include -#include #include +#include #include namespace @@ -275,9 +275,9 @@ sf::Keyboard::Scancode translateKeyCode(Display* display, KeyCode keycode) } //////////////////////////////////////////////////////////// -std::map getNameScancodeMap() +std::unordered_map getNameScancodeMap() { - std::map mapping; + std::unordered_map mapping; mapping.emplace("LSGT", sf::Keyboard::Scan::NonUsBackslash); @@ -471,8 +471,8 @@ void ensureMapping() XkbDescPtr descriptor = XkbGetMap(display, 0, XkbUseCoreKbd); XkbGetNames(display, XkbKeyNamesMask, descriptor); - std::map nameScancodeMap = getNameScancodeMap(); - sf::Keyboard::Scancode scancode = sf::Keyboard::Scan::Unknown; + std::unordered_map nameScancodeMap = getNameScancodeMap(); + sf::Keyboard::Scancode scancode = sf::Keyboard::Scan::Unknown; for (int keycode = descriptor->min_key_code; keycode <= descriptor->max_key_code; ++keycode) { @@ -484,8 +484,9 @@ void ensureMapping() std::memcpy(name, descriptor->names->keys[keycode].name, XkbKeyNameLength); name[XkbKeyNameLength] = '\0'; - std::map::iterator mappedScancode = nameScancodeMap.find(std::string(name)); - scancode = sf::Keyboard::Scan::Unknown; + std::unordered_map::iterator mappedScancode = nameScancodeMap.find( + std::string(name)); + scancode = sf::Keyboard::Scan::Unknown; if (mappedScancode != nameScancodeMap.end()) scancode = mappedScancode->second;