summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2019-01-04 20:48:06 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2019-02-04 15:29:09 +0100
commit780858355914c64793f11860490603c5131c35f1 (patch)
tree7f0a35d980a457d1be6a49e7e2886755306de9cd /apt-pkg
parent2cc1b3a3ee595c8be761fee309167b8a56393d3e (diff)
Use std::to_string() for HashStringList::FileSize() getter
This slightly improves performance, as std::to_string() (as in gcc's libstdc++) avoids a heap allocation. This is surprisingly performance critical code, so we might want to improve things further in 1.9 by manually calculating the string - that would also get rid of issues with locales changing string formatting, if any.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/hashes.cc4
1 files changed, 1 insertions, 3 deletions
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 630a2e674..98b92cc81 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -207,9 +207,7 @@ unsigned long long HashStringList::FileSize() const /*{{{*/
/*}}}*/
bool HashStringList::FileSize(unsigned long long const Size) /*{{{*/
{
- std::string size;
- strprintf(size, "%llu", Size);
- return push_back(HashString("Checksum-FileSize", size));
+ return push_back(HashString("Checksum-FileSize", std::to_string(Size)));
}
/*}}}*/
bool HashStringList::supported(char const * const type) /*{{{*/