Use std::unordered_map in KeyCharacterMap
Previously, KeyedVector was used in KeyCharacterMap. Convert this to the
std::unordered_map.
Bug: 278299254
Test: m checkinput
Test: m libinput_tests && $ANDROID_HOST_OUT/nativetest64/libinput_tests/libinput_tests
Change-Id: I643aa8cc8ae0c68ade4d11d02e34be64faf7f157
diff --git a/include/input/KeyCharacterMap.h b/include/input/KeyCharacterMap.h
index 9423041..b2e8baa 100644
--- a/include/input/KeyCharacterMap.h
+++ b/include/input/KeyCharacterMap.h
@@ -26,9 +26,9 @@
#include <android-base/result.h>
#include <input/Input.h>
#include <utils/Errors.h>
-#include <utils/KeyedVector.h>
#include <utils/Tokenizer.h>
#include <utils/Unicode.h>
+#include <map>
// Maximum number of keys supported by KeyCharacterMaps
#define MAX_KEYS 8192
@@ -152,13 +152,9 @@
void writeToParcel(Parcel* parcel) const;
#endif
- bool operator==(const KeyCharacterMap& other) const;
+ bool operator==(const KeyCharacterMap& other) const = default;
- bool operator!=(const KeyCharacterMap& other) const;
-
- KeyCharacterMap(const KeyCharacterMap& other);
-
- virtual ~KeyCharacterMap();
+ KeyCharacterMap(const KeyCharacterMap& other) = default;
private:
struct Behavior {
@@ -173,17 +169,18 @@
/* The replacement keycode if the key has to be replaced outright. */
int32_t replacementKeyCode = 0;
+
+ bool operator==(const Behavior&) const = default;
};
struct Key {
- Key();
- Key(const Key& other);
+ bool operator==(const Key&) const = default;
/* The single character label printed on the key, or 0 if none. */
- char16_t label;
+ char16_t label = 0;
/* The number or symbol character generated by the key, or 0 if none. */
- char16_t number;
+ char16_t number = 0;
/* The list of key behaviors sorted from most specific to least specific
* meta key binding. */
@@ -218,7 +215,6 @@
public:
Parser(KeyCharacterMap* map, Tokenizer* tokenizer, Format format);
- ~Parser();
status_t parse();
private:
@@ -232,8 +228,8 @@
status_t parseCharacterLiteral(char16_t* outCharacter);
};
- KeyedVector<int32_t, Key*> mKeys;
- KeyboardType mType;
+ std::map<int32_t, Key> mKeys;
+ KeyboardType mType = KeyboardType::UNKNOWN;
std::string mLoadFileName;
bool mLayoutOverlayApplied = false;