Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

Commit

Permalink
mapped_file: Access path by const reference
Browse files Browse the repository at this point in the history
Clang warned this copies path each time it is used, despite never modifying the data. It recommended const reference to achieve the same goal.
  • Loading branch information
lat9nq committed Apr 1, 2024
1 parent 2ba0b96 commit 76be900
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion source/mapped_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

mapped_file::mapped_file() : _path(), _file(), _map(), _ptr() {}

mapped_file::mapped_file(std::filesystem::path path) : _path(path)
mapped_file::mapped_file(const std::filesystem::path& path) : _path(path)
{
#ifdef WIN32
_file.reset(CreateFileA(reinterpret_cast<LPCSTR>(path.generic_string().c_str()), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL), [](void* p) { CloseHandle(p); });
Expand Down
2 changes: 1 addition & 1 deletion source/mapped_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class mapped_file {

public:
mapped_file();
mapped_file(std::filesystem::path path);
mapped_file(const std::filesystem::path& path);

~mapped_file();

Expand Down

0 comments on commit 76be900

Please sign in to comment.