]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
perf: Avoid value initialization of data in util::Bytes
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 10 Feb 2024 09:14:44 +0000 (10:14 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 11 Feb 2024 13:18:20 +0000 (14:18 +0100)
src/util/Bytes.cpp

index 1b4007e52d2f247eec97bfe690464339dc6dceaf..32d181881b2474cd6cdc8caaf1506baec8ed6e1e 100644 (file)
@@ -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<uint8_t[]>(size);
+    // In C++20, use std::make_unique_for_overwrite instead.
+    auto new_data = std::unique_ptr<uint8_t[]>(new uint8_t[size]);
     if (m_size > 0) {
       std::memcpy(new_data.get(), m_data.get(), m_size);
     }