summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcachegen.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-01-08 01:27:01 +0100
committerJulian Andres Klode <jak@debian.org>2016-01-08 01:30:18 +0100
commit869700d839a1695fe00734592bd504d59386e4b9 (patch)
tree3ad6f069d50aa4d44cc733c11b1231d04df4856b /apt-pkg/pkgcachegen.cc
parent57590d3c6e6b055402c938c3baebf1d872c58f7e (diff)
pkgCacheGenerator::StoreString: Get rid of std::string
Instead of storing a string -> map_stringitem_t mapping, create our own data type that can point to either a normal string or a string inside the cache. This avoids the creation of any string and improves performance slightly (about 4%).
Diffstat (limited to 'apt-pkg/pkgcachegen.cc')
-rw-r--r--apt-pkg/pkgcachegen.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 577a6e474..79d633cb7 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -1257,23 +1257,21 @@ bool pkgCacheGenerator::SelectFile(std::string const &File,
map_stringitem_t pkgCacheGenerator::StoreString(enum StringType const type, const char *S,
unsigned int Size)
{
- std::string key(S, Size);
-
- std::unordered_map<std::string,map_stringitem_t> * strings;
+ auto strings = &strMixed;
switch(type) {
case MIXED: strings = &strMixed; break;
case PKGNAME: strings = &strPkgNames; break;
case VERSIONNUMBER: strings = &strVersions; break;
case SECTION: strings = &strSections; 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'", Size, S); return 0;
}
- std::unordered_map<std::string,map_stringitem_t>::const_iterator const item = strings->find(key);
+ auto const item = strings->find({S, Size, nullptr, 0});
if (item != strings->end())
- return item->second;
+ return item->item;
map_stringitem_t const idxString = WriteStringInMap(S,Size);
- strings->insert(std::make_pair(std::move(key), idxString));
+ strings->insert({nullptr, Size, this, idxString});
return idxString;
}
/*}}}*/