diff options
| author | 2018-07-20 15:27:17 -0400 | |
|---|---|---|
| committer | 2018-07-20 15:27:20 -0400 | |
| commit | 457d1b4490dbc293246f372532a81a9e90d366c4 (patch) | |
| tree | 93eb2026cadad03ab9d52be843a9446ff180ecf0 /src/common/logging/backend.cpp | |
| parent | Merge pull request #740 from Subv/acc_crash (diff) | |
| download | yuzu-457d1b4490dbc293246f372532a81a9e90d366c4.tar.gz yuzu-457d1b4490dbc293246f372532a81a9e90d366c4.tar.xz yuzu-457d1b4490dbc293246f372532a81a9e90d366c4.zip | |
logging/backend: Use std::string_view in RemoveBackend() and GetBackend()
These can just use a view to a string since its only comparing against
two names in both cases for matches. This avoids constructing
std::string instances where they aren't necessary.
Diffstat (limited to 'src/common/logging/backend.cpp')
| -rw-r--r-- | src/common/logging/backend.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index ed1e93cc2..3745af9df 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -48,11 +48,11 @@ public: | |||
| 48 | backends.push_back(std::move(backend)); | 48 | backends.push_back(std::move(backend)); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | void RemoveBackend(const std::string& backend_name) { | 51 | void RemoveBackend(std::string_view backend_name) { |
| 52 | std::lock_guard<std::mutex> lock(writing_mutex); | 52 | std::lock_guard<std::mutex> lock(writing_mutex); |
| 53 | auto it = std::remove_if(backends.begin(), backends.end(), [&backend_name](const auto& i) { | 53 | const auto it = |
| 54 | return !strcmp(i->GetName(), backend_name.c_str()); | 54 | std::remove_if(backends.begin(), backends.end(), |
| 55 | }); | 55 | [&backend_name](const auto& i) { return backend_name == i->GetName(); }); |
| 56 | backends.erase(it, backends.end()); | 56 | backends.erase(it, backends.end()); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| @@ -64,10 +64,10 @@ public: | |||
| 64 | filter = f; | 64 | filter = f; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | Backend* GetBackend(const std::string& backend_name) { | 67 | Backend* GetBackend(std::string_view backend_name) { |
| 68 | auto it = std::find_if(backends.begin(), backends.end(), [&backend_name](const auto& i) { | 68 | const auto it = |
| 69 | return !strcmp(i->GetName(), backend_name.c_str()); | 69 | std::find_if(backends.begin(), backends.end(), |
| 70 | }); | 70 | [&backend_name](const auto& i) { return backend_name == i->GetName(); }); |
| 71 | if (it == backends.end()) | 71 | if (it == backends.end()) |
| 72 | return nullptr; | 72 | return nullptr; |
| 73 | return it->get(); | 73 | return it->get(); |
| @@ -265,11 +265,11 @@ void AddBackend(std::unique_ptr<Backend> backend) { | |||
| 265 | Impl::Instance().AddBackend(std::move(backend)); | 265 | Impl::Instance().AddBackend(std::move(backend)); |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | void RemoveBackend(const std::string& backend_name) { | 268 | void RemoveBackend(std::string_view backend_name) { |
| 269 | Impl::Instance().RemoveBackend(backend_name); | 269 | Impl::Instance().RemoveBackend(backend_name); |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | Backend* GetBackend(const std::string& backend_name) { | 272 | Backend* GetBackend(std::string_view backend_name) { |
| 273 | return Impl::Instance().GetBackend(backend_name); | 273 | return Impl::Instance().GetBackend(backend_name); |
| 274 | } | 274 | } |
| 275 | 275 | ||