summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-01-07 19:55:48 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2020-01-14 13:10:36 +0100
commitb350560e34a369ef7610f9fceeffb00660209390 (patch)
tree4a0def641d79b2d2ecf570a490d6cf264d58c01e /apt-pkg/contrib
parent814ffcfaf34ad1d35e397eeaaafefbf03faed9cf (diff)
Raise buffer size for Hashes::AddFD() from 4 KiB to 64 KiB
Move APT_BUFFER_SIZE to macros.h and re-use it in hashes, this also might speed up stuff, the motivation for using 64 KiB buffers in fileutl.cc was precisely that after all.
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/fileutl.cc3
-rw-r--r--apt-pkg/contrib/hashes.cc5
-rw-r--r--apt-pkg/contrib/macros.h3
3 files changed, 6 insertions, 5 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index b83a4bad7..db5463be2 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -85,9 +85,6 @@
using namespace std;
-/* Should be a multiple of the common page size (4096) */
-static constexpr unsigned long long APT_BUFFER_SIZE = 64 * 1024;
-
// RunScripts - Run a set of scripts from a configuration subtree /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index d68919778..8ddaaf549 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -15,6 +15,7 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/hashes.h>
+#include <apt-pkg/macros.h>
#include <algorithm>
#include <iostream>
@@ -336,7 +337,7 @@ bool Hashes::Add(const unsigned char * const Data, unsigned long long const Size
}
bool Hashes::AddFD(int const Fd,unsigned long long Size)
{
- unsigned char Buf[64*64];
+ unsigned char Buf[APT_BUFFER_SIZE];
bool const ToEOF = (Size == UntilEOF);
while (Size != 0 || ToEOF)
{
@@ -355,7 +356,7 @@ bool Hashes::AddFD(int const Fd,unsigned long long Size)
}
bool Hashes::AddFD(FileFd &Fd,unsigned long long Size)
{
- unsigned char Buf[64*64];
+ unsigned char Buf[APT_BUFFER_SIZE];
bool const ToEOF = (Size == 0);
while (Size != 0 || ToEOF)
{
diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h
index 340549fbd..7e42092f6 100644
--- a/apt-pkg/contrib/macros.h
+++ b/apt-pkg/contrib/macros.h
@@ -128,4 +128,7 @@
#define APT_PKG_590(msg)
#endif
+/* Should be a multiple of the common page size (4096) */
+static constexpr unsigned long long APT_BUFFER_SIZE = 64 * 1024;
+
#endif