summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/strutl.cc
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/strutl.cc
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/strutl.cc')
-rw-r--r--apt-pkg/contrib/strutl.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index b9bfc2c98..856e5ee9f 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1114,12 +1114,17 @@ static int HexDigit(int c)
/* The length of the buffer must be exactly 1/2 the length of the string. */
bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length)
{
+ return Hex2Num(APT::StringView(Str), Num, Length);
+}
+
+bool Hex2Num(const APT::StringView Str,unsigned char *Num,unsigned int Length)
+{
if (Str.length() != Length*2)
return false;
// Convert each digit. We store it in the same order as the string
int J = 0;
- for (string::const_iterator I = Str.begin(); I != Str.end();J++, I += 2)
+ for (auto I = Str.begin(); I != Str.end();J++, I += 2)
{
int first_half = HexDigit(I[0]);
int second_half;