Switch from std::map<> to std::unordered_map<> where possible

Didn't switch env_var_t map because it seems to be mostly iterated in
order, but that decision may be revisited at a later date.
This commit is contained in:
Mahmoud Al-Qudsi
2017-08-19 11:55:06 -05:00
parent 0dce9a2114
commit 61b4900a70
12 changed files with 45 additions and 28 deletions

View File

@@ -30,9 +30,9 @@
#endif
#include <algorithm>
#include <map>
#include <set>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
@@ -85,7 +85,7 @@ bool term_has_xn = false;
/// found in `TERMINFO_DIRS` we don't to call `handle_curses()` before we've imported the latter.
static bool env_initialized = false;
typedef std::map<const wcstring, void (*)(const wcstring &, const wcstring &)> var_dispatch_table_t;
typedef std::unordered_map<const wcstring, void (*)(const wcstring &, const wcstring &)> var_dispatch_table_t;
var_dispatch_table_t var_dispatch_table;
/// List of all locale environment variable names that might trigger (re)initializing the locale
@@ -1596,7 +1596,7 @@ env_var_t env_vars_snapshot_t::get(const wcstring &key) const {
if (this->is_current()) {
return env_get(key);
}
std::map<wcstring, env_var_t>::const_iterator iter = vars.find(key);
auto iter = vars.find(key);
return iter == vars.end() ? missing_var : env_var_t(iter->second);
}