From bebc19da3253f13ceb5abfe8560cdbdc32ea7d8a Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 25 Sep 2026 07:54:49 +0200 Subject: [common] Use `std::make_unique_for_overwrite` in ScratchBuffer, remove polyfill (#4432) Original `make_unique_for_overwrite.h` is well defined acc. to standard https://en.cppreference.com/cpp/memory/unique_ptr/make_unique, but by now most libc++ supports the function, so no need for polyfill. Test that this didn't break anything (for example, Megaman game that has video at the start), or anything using VIC/IPC. Signed-off-by: lizzie - [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4432 Reviewed-by: MaranBr Reviewed-by: CamilleLaVey --- src/core/file_sys/vfs/vfs_real.cpp | 7 +++---- src/core/file_sys/vfs/vfs_real.h | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/core/file_sys') 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/file_sys/vfs/vfs_real.h b/src/core/file_sys/vfs/vfs_real.h index 672126d7ba..a97f7d32ea 100644 --- a/src/core/file_sys/vfs/vfs_real.h +++ b/src/core/file_sys/vfs/vfs_real.h @@ -82,6 +82,9 @@ class RealVfsFile : public VfsFile { friend class RealVfsFilesystem; public: + RealVfsFile(RealVfsFilesystem& base, std::unique_ptr reference, + const std::string& path, OpenMode perms = OpenMode::Read, + std::optional size = {}, std::optional parent_path = {}); ~RealVfsFile() override; std::string GetName() const override; @@ -95,9 +98,6 @@ public: bool Rename(std::string_view name) override; private: - RealVfsFile(RealVfsFilesystem& base, std::unique_ptr reference, - const std::string& path, OpenMode perms = OpenMode::Read, - std::optional size = {}, std::optional parent_path = {}); RealVfsFilesystem& base; std::unique_ptr reference; @@ -113,6 +113,8 @@ class RealVfsDirectory : public VfsDirectory { friend class RealVfsFilesystem; public: + RealVfsDirectory(RealVfsFilesystem& base, const std::string& path, + OpenMode perms = OpenMode::Read); ~RealVfsDirectory() override; VirtualFile GetFileRelative(std::string_view relative_path) const override; @@ -138,9 +140,6 @@ public: std::map> GetEntries() const override; private: - RealVfsDirectory(RealVfsFilesystem& base, const std::string& path, - OpenMode perms = OpenMode::Read); - template std::vector> IterateEntries() const; -- cgit v1.2.3