std::unordered_map is faster than std::map in our use case,
reducing cache generation time by about 10% in my benchmark.
{
std::string const key(S, Size);
{
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;
switch(type) {
case MIXED: strings = &strMixed; break;
case PKGNAME: strings = &strPkgNames; break;
default: _error->Fatal("Unknown enum type used for string storage of '%s'", key.c_str()); return 0;
}
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;
if (item != strings->end())
return item->second;
#include <vector>
#include <string>
#include <vector>
#include <string>
+#include <unordered_map>
class FileFd;
class pkgSourceList;
class FileFd;
class pkgSourceList;
APT_HIDDEN map_stringitem_t WriteStringInMap(const char *String, const unsigned long &Len);
APT_HIDDEN map_pointer_t AllocateInMap(const unsigned long &size);
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;
friend class pkgCacheListParser;
typedef pkgCacheListParser ListParser;