From: Joel Rosdahl Date: Sat, 10 Feb 2024 09:14:44 +0000 (+0100) Subject: perf: Avoid value initialization of data in util::Bytes X-Git-Tag: v4.10~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3512ae3e7418cf75c5c57ee7d8e09ab576020c4;p=thirdparty%2Fccache.git perf: Avoid value initialization of data in util::Bytes --- diff --git a/src/util/Bytes.cpp b/src/util/Bytes.cpp index 1b4007e5..32d18188 100644 --- a/src/util/Bytes.cpp +++ b/src/util/Bytes.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2022-2023 Joel Rosdahl and other contributors +// Copyright (C) 2022-2024 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -120,7 +120,8 @@ void Bytes::resize(size_t size) noexcept { if (size > m_capacity) { - auto new_data = std::make_unique(size); + // In C++20, use std::make_unique_for_overwrite instead. + auto new_data = std::unique_ptr(new uint8_t[size]); if (m_size > 0) { std::memcpy(new_data.get(), m_data.get(), m_size); }