From 69bb6c06c6c3d84bbf375f49782ad58a1d0f05ee Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 15 Sep 2026 07:13:48 +0000 Subject: [PATCH] 2026-09-15 07:13:48 Signed-off-by: lizzie --- src/common/CMakeLists.txt | 1 - src/common/make_unique_for_overwrite.h | 27 ------------------- src/common/scratch_buffer.h | 12 ++++----- src/core/file_sys/vfs/vfs_real.cpp | 7 +++-- .../hle/service/psc/ovln/receiver_service.cpp | 2 +- 5 files changed, 10 insertions(+), 39 deletions(-) delete mode 100644 src/common/make_unique_for_overwrite.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 61e0e64aa8..f279d55f8d 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -76,7 +76,6 @@ add_library( logging.h lz4_compression.cpp lz4_compression.h - make_unique_for_overwrite.h math_util.h memory_detect.cpp memory_detect.h diff --git a/src/common/make_unique_for_overwrite.h b/src/common/make_unique_for_overwrite.h deleted file mode 100644 index 17f81bba4a..0000000000 --- a/src/common/make_unique_for_overwrite.h +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include -#include - -namespace Common { - -template - requires(!std::is_array_v) -std::unique_ptr make_unique_for_overwrite() { - return std::unique_ptr(new T); -} - -template - requires std::is_unbounded_array_v -std::unique_ptr make_unique_for_overwrite(std::size_t n) { - return std::unique_ptr(new std::remove_extent_t[n]); -} - -template - requires std::is_bounded_array_v -void make_unique_for_overwrite(Args&&...) = delete; - -} // namespace Common diff --git a/src/common/scratch_buffer.h b/src/common/scratch_buffer.h index 8c1f566301..929a65609a 100644 --- a/src/common/scratch_buffer.h +++ b/src/common/scratch_buffer.h @@ -8,8 +8,7 @@ #include #include - -#include "common/make_unique_for_overwrite.h" +#include namespace Common { @@ -38,8 +37,9 @@ public: ScratchBuffer() = default; explicit ScratchBuffer(size_type initial_capacity) - : last_requested_size{initial_capacity}, buffer_capacity{initial_capacity}, - buffer{Common::make_unique_for_overwrite(initial_capacity)} {} + : last_requested_size{initial_capacity} + , buffer_capacity{initial_capacity} + , buffer{std::make_unique_for_overwrite(initial_capacity)} {} ~ScratchBuffer() = default; ScratchBuffer(const ScratchBuffer&) = delete; @@ -64,7 +64,7 @@ public: /// The previously held data will remain intact. void resize(size_type size) { if (size > buffer_capacity) { - auto new_buffer = Common::make_unique_for_overwrite(size); + auto new_buffer = std::make_unique_for_overwrite(size); std::memcpy(new_buffer.get(), buffer.get(), buffer_capacity * sizeof(T)); buffer = std::move(new_buffer); buffer_capacity = size; @@ -77,7 +77,7 @@ public: void resize_destructive(size_type size) { if (size > buffer_capacity) { buffer_capacity = size; - buffer = Common::make_unique_for_overwrite(buffer_capacity); + buffer = std::make_unique_for_overwrite(buffer_capacity); } last_requested_size = size; } diff --git a/src/core/file_sys/vfs/vfs_real.cpp b/src/core/file_sys/vfs/vfs_real.cpp index b04f832cd3..14e0caad3c 100644 --- a/src/core/file_sys/vfs/vfs_real.cpp +++ b/src/core/file_sys/vfs/vfs_real.cpp @@ -109,8 +109,7 @@ VirtualFile RealVfsFilesystem::OpenFileFromEntry(std::string_view path_, std::op auto reference = std::make_unique(); this->InsertReferenceIntoListLocked(*reference); - auto file = std::shared_ptr( - new RealVfsFile(*this, std::move(reference), path, perms, size, std::move(parent_path))); + auto file = std::make_shared(*this, std::move(reference), path, perms, size, std::move(parent_path)); cache[path] = file; return file; @@ -177,7 +176,7 @@ bool RealVfsFilesystem::DeleteFile(std::string_view path_) { VirtualDir RealVfsFilesystem::OpenDirectory(std::string_view path_, OpenMode perms) { const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); - return std::shared_ptr(new RealVfsDirectory(*this, path, perms)); + return std::make_shared(*this, path, perms); } VirtualDir RealVfsFilesystem::CreateDirectory(std::string_view path_, OpenMode perms) { @@ -185,7 +184,7 @@ VirtualDir RealVfsFilesystem::CreateDirectory(std::string_view path_, OpenMode p if (!FS::CreateDirs(path)) { return nullptr; } - return std::shared_ptr(new RealVfsDirectory(*this, path, perms)); + return std::make_shared(*this, path, perms); } VirtualDir RealVfsFilesystem::CopyDirectory(std::string_view old_path_, diff --git a/src/core/hle/service/psc/ovln/receiver_service.cpp b/src/core/hle/service/psc/ovln/receiver_service.cpp index d869325181..a9cee65795 100644 --- a/src/core/hle/service/psc/ovln/receiver_service.cpp +++ b/src/core/hle/service/psc/ovln/receiver_service.cpp @@ -24,7 +24,7 @@ IReceiverService::~IReceiverService() = default; Result IReceiverService::OpenReceiver(Out> out_receiver) { LOG_DEBUG(Service_PSC, "called"); - *out_receiver = std::shared_ptr(new IReceiver(system)); + *out_receiver = std::make_shared(system); R_SUCCEED(); }