summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/hashsum_template.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/contrib/hashsum_template.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/contrib/hashsum_template.h')
-rw-r--r--apt-pkg/contrib/hashsum_template.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h
index d0ea0971e..42248f6ac 100644
--- a/apt-pkg/contrib/hashsum_template.h
+++ b/apt-pkg/contrib/hashsum_template.h
@@ -13,6 +13,9 @@
#include <string>
#include <cstring>
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+#include <apt-pkg/string_view.h>
+#endif
#include <apt-pkg/strutl.h>
@@ -80,7 +83,16 @@ class HashSumValue
{
return Hex2Num(Str,Sum,sizeof(Sum));
}
-
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+ APT_HIDDEN bool Set(APT::StringView Str)
+ {
+ return Hex2Num(Str,Sum,sizeof(Sum));
+ }
+ APT_HIDDEN bool Set(const char *Str)
+ {
+ return Hex2Num(APT::StringView(Str),Sum,sizeof(Sum));
+ }
+#endif
inline void Set(unsigned char S[N/8])
{
for (int I = 0; I != sizeof(Sum); ++I)
@@ -92,6 +104,18 @@ class HashSumValue
memset(Sum,0,sizeof(Sum));
Set(Str);
}
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+ APT_HIDDEN explicit HashSumValue(APT::StringView const &Str)
+ {
+ memset(Sum,0,sizeof(Sum));
+ Set(Str);
+ }
+ APT_HIDDEN explicit HashSumValue(const char *Str)
+ {
+ memset(Sum,0,sizeof(Sum));
+ Set(Str);
+ }
+#endif
HashSumValue()
{
memset(Sum,0,sizeof(Sum));