diff options
| author | Neil <nyamatongwe@gmail.com> | 2014-01-02 12:45:19 +1100 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2014-01-02 12:45:19 +1100 | 
| commit | b699bfc80e3b242795c9e7cbb0d1ac8b48750959 (patch) | |
| tree | 317ee8886d9a45cd9be2127eb07134bb3cf2519f /src/KeyMap.cxx | |
| parent | c64f8a2c10db3fb9c023498d821d681f04ee2e7e (diff) | |
| download | scintilla-mirror-b699bfc80e3b242795c9e7cbb0d1ac8b48750959.tar.gz | |
Use a std::map for KeyMap to avoid custom iteration in favour of standard
provided functionality.
Diffstat (limited to 'src/KeyMap.cxx')
| -rw-r--r-- | src/KeyMap.cxx | 21 | 
1 files changed, 4 insertions, 17 deletions
| diff --git a/src/KeyMap.cxx b/src/KeyMap.cxx index 740776104..cb6f2b8d4 100644 --- a/src/KeyMap.cxx +++ b/src/KeyMap.cxx @@ -8,6 +8,7 @@  #include <stdlib.h>  #include <vector> +#include <map>  #include "Platform.h" @@ -36,26 +37,12 @@ void KeyMap::Clear() {  }  void KeyMap::AssignCmdKey(int key, int modifiers, unsigned int msg) { -	for (size_t keyIndex = 0; keyIndex < kmap.size(); keyIndex++) { -		if ((key == kmap[keyIndex].key) && (modifiers == kmap[keyIndex].modifiers)) { -			kmap[keyIndex].msg = msg; -			return; -		} -	} -	KeyToCommand ktc; -	ktc.key = key; -	ktc.modifiers = modifiers; -	ktc.msg = msg; -	kmap.push_back(ktc); +	kmap[KeyModifiers(key, modifiers)] = msg;  }  unsigned int KeyMap::Find(int key, int modifiers) const { -	for (size_t i = 0; i < kmap.size(); i++) { -		if ((key == kmap[i].key) && (modifiers == kmap[i].modifiers)) { -			return kmap[i].msg; -		} -	} -	return 0; +	std::map<KeyModifiers, unsigned int>::const_iterator it = kmap.find(KeyModifiers(key, modifiers)); +	return (it == kmap.end()) ? 0 : it->second;  }  #if PLAT_GTK_MACOSX | 
