From 780858355914c64793f11860490603c5131c35f1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 4 Jan 2019 20:48:06 +0100 Subject: 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. --- apt-pkg/contrib/hashes.cc | 4 +--- 1 file changed, 1 insertion(+), 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) /*{{{*/ -- cgit v1.2.3