tag/Id3Load, ...: use std::make_unique_for_overwrite()

Don't zero-initialize the buffers.  This removes some useless
overhead.
This commit is contained in:
Max Kellermann
2025-01-29 11:52:35 +01:00
parent a5da7fd51a
commit 57e7fb3f62
10 changed files with 13 additions and 13 deletions

View File

@@ -50,7 +50,7 @@ try {
remaining -= sizeof(footer);
assert(remaining > 10);
auto buffer = std::make_unique<std::byte[]>(remaining);
auto buffer = std::make_unique_for_overwrite<std::byte[]>(remaining);
is.ReadFull(lock, {buffer.get(), remaining});
/* read tags */

View File

@@ -47,7 +47,7 @@ try {
/* we have enough data already */
return UniqueId3Tag(id3_tag_parse(query_buffer, tag_size));
auto tag_buffer = std::make_unique<id3_byte_t[]>(tag_size);
auto tag_buffer = std::make_unique_for_overwrite<id3_byte_t[]>(tag_size);
/* copy the start of the tag we already have to the allocated
buffer */
@@ -182,7 +182,7 @@ try {
/* too large, don't allocate so much memory */
return nullptr;
auto buffer = std::make_unique<id3_byte_t[]>(size);
auto buffer = std::make_unique_for_overwrite<id3_byte_t[]>(size);
is.ReadFull(lock, std::as_writable_bytes(std::span{buffer.get(), size}));
return UniqueId3Tag(id3_tag_parse(buffer.get(), size));