summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcache.h
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-01-07 19:16:23 +0100
committerJulian Andres Klode <jak@debian.org>2016-01-07 19:59:08 +0100
commiteff0c22e59e65b6b63e854ff41eb091278e05714 (patch)
tree8496b397479c397085bb57dd4756c9113b4e2cbf /apt-pkg/pkgcache.h
parentfe7fa47c1141066c89ab3382c318a4b9d00fe249 (diff)
Switch performance critical code to use APT::StringView
This improves performance of the cache generation on my ARM platform (4x Cortex A15) by about 10% to 20% from 2.35-2.50 to 2.1 seconds.
Diffstat (limited to 'apt-pkg/pkgcache.h')
-rw-r--r--apt-pkg/pkgcache.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index 7acfc01ba..9fea44e06 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -81,6 +81,10 @@
#include <time.h>
#include <stdint.h>
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+#include <apt-pkg/string_view.h>
+#endif
+
#ifndef APT_8_CLEANER_HEADERS
using std::string;
#endif
@@ -193,7 +197,9 @@ class pkgCache /*{{{*/
// Memory mapped cache file
std::string CacheFile;
MMap &Map;
-
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+ APT_HIDDEN map_id_t sHash(APT::StringView S) const APT_PURE;
+#endif
map_id_t sHash(const std::string &S) const APT_PURE;
map_id_t sHash(const char *S) const APT_PURE;
@@ -221,6 +227,9 @@ class pkgCache /*{{{*/
inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();}
// String hashing function (512 range)
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+ APT_HIDDEN inline map_id_t Hash(APT::StringView S) const {return sHash(S);}
+#endif
inline map_id_t Hash(const std::string &S) const {return sHash(S);}
inline map_id_t Hash(const char *S) const {return sHash(S);}
@@ -230,6 +239,12 @@ class pkgCache /*{{{*/
static const char *Priority(unsigned char Priority);
// Accessors
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+ APT_HIDDEN GrpIterator FindGrp(APT::StringView Name);
+ APT_HIDDEN PkgIterator FindPkg(APT::StringView Name);
+ APT_HIDDEN PkgIterator FindPkg(APT::StringView Name, APT::StringView Arch);
+#endif
+
GrpIterator FindGrp(const std::string &Name);
PkgIterator FindPkg(const std::string &Name);
PkgIterator FindPkg(const std::string &Name, const std::string &Arch);