diff options
author | Julian Andres Klode <jak@debian.org> | 2015-12-27 01:33:38 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2015-12-27 01:46:06 +0100 |
commit | e9185eca390435b4060ef26c7c69d39f994da7a7 (patch) | |
tree | d77ecc772e65180b9ff0bad0a5a6961b7e60d426 /apt-pkg | |
parent | 74dedb4ae28fd4f7c89bf769708d4f7edc7ed79a (diff) |
pkgcachegen: Use std::unordered_map instead of std::map
std::unordered_map is faster than std::map in our use case,
reducing cache generation time by about 10% in my benchmark.
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/pkgcachegen.cc | 4 | ||||
-rw-r--r-- | apt-pkg/pkgcachegen.h | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 61f7a1124..e7bdc615b 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -1253,7 +1253,7 @@ map_stringitem_t pkgCacheGenerator::StoreString(enum StringType const type, cons { std::string const key(S, Size); - std::map<std::string,map_stringitem_t> * strings; + std::unordered_map<std::string,map_stringitem_t> * strings; switch(type) { case MIXED: strings = &strMixed; break; case PKGNAME: strings = &strPkgNames; break; @@ -1262,7 +1262,7 @@ map_stringitem_t pkgCacheGenerator::StoreString(enum StringType const type, cons default: _error->Fatal("Unknown enum type used for string storage of '%s'", key.c_str()); return 0; } - std::map<std::string,map_stringitem_t>::const_iterator const item = strings->find(key); + std::unordered_map<std::string,map_stringitem_t>::const_iterator const item = strings->find(key); if (item != strings->end()) return item->second; diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index 328d296bf..9001e334f 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -26,7 +26,7 @@ #include <vector> #include <string> -#include <map> +#include <unordered_map> class FileFd; class pkgSourceList; @@ -41,10 +41,10 @@ class APT_HIDDEN pkgCacheGenerator /*{{{*/ APT_HIDDEN map_stringitem_t WriteStringInMap(const char *String, const unsigned long &Len); APT_HIDDEN map_pointer_t AllocateInMap(const unsigned long &size); - std::map<std::string,map_stringitem_t> strMixed; - std::map<std::string,map_stringitem_t> strSections; - std::map<std::string,map_stringitem_t> strPkgNames; - std::map<std::string,map_stringitem_t> strVersions; + std::unordered_map<std::string,map_stringitem_t> strMixed; + std::unordered_map<std::string,map_stringitem_t> strSections; + std::unordered_map<std::string,map_stringitem_t> strPkgNames; + std::unordered_map<std::string,map_stringitem_t> strVersions; friend class pkgCacheListParser; typedef pkgCacheListParser ListParser; |