summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-09-27 18:28:55 +0200
committerJulian Andres Klode <jak@debian.org>2016-11-22 22:58:18 +0100
commitf903069c139df58d1ba855f7cf02c4a2d4e51dc3 (patch)
treeafeaaa1079fd67e99d7ab37f68eecb37988d5161 /apt-pkg/contrib
parent7a3b00b10b6a5a740e07fc1b68a4f3fb3bcdac23 (diff)
Optimize VersionHash() to not need temporary copy of input
Stop copying stuff, and just parse the bytes one by-one to the newly created AddCRC16Byte. This improves the instruction count for an update run from 720,850,121 to 455,801,749 according to callgrind.
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/crc-16.cc4
-rw-r--r--apt-pkg/contrib/crc-16.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/apt-pkg/contrib/crc-16.cc b/apt-pkg/contrib/crc-16.cc
index f5df2d8b1..250d7664a 100644
--- a/apt-pkg/contrib/crc-16.cc
+++ b/apt-pkg/contrib/crc-16.cc
@@ -64,6 +64,10 @@ static unsigned short const crc16_table[256] =
/* Recompute the FCS with one more character appended. */
#define CalcFCS(fcs, c) (((fcs) >> 8) ^ crc16_table[((fcs) ^ (c)) & 0xff])
+unsigned short AddCRC16Byte(unsigned short fcs, unsigned char byte)
+{
+ return CalcFCS(fcs, byte);
+}
unsigned short AddCRC16(unsigned short fcs, void const *Buf,
unsigned long long len)
{
diff --git a/apt-pkg/contrib/crc-16.h b/apt-pkg/contrib/crc-16.h
index 08acdafb7..6cc3556c6 100644
--- a/apt-pkg/contrib/crc-16.h
+++ b/apt-pkg/contrib/crc-16.h
@@ -13,6 +13,7 @@
#include <apt-pkg/macros.h>
#define INIT_FCS 0xffff
+unsigned short AddCRC16Byte(unsigned short fcs, unsigned char byte) APT_CONST;
unsigned short AddCRC16(unsigned short fcs, void const *buf,
unsigned long long len) APT_PURE;