summaryrefslogtreecommitdiffhomepage
path: root/main/editor.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-20 22:19:35 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-20 22:19:35 +0200
commit2eb8a266fd01bb0c6b57a40b16e1dc8ea927b522 (patch)
treec1812d35a63e9d4d329100de89f0b6fefb03869a /main/editor.cpp
parentaf931eef1537cd4206eefcb981be75a2d01cba17 (diff)
editor: avoid allocating std::string
Diffstat (limited to 'main/editor.cpp')
-rw-r--r--main/editor.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/main/editor.cpp b/main/editor.cpp
index 04578adb..0fd6ca34 100644
--- a/main/editor.cpp
+++ b/main/editor.cpp
@@ -6,6 +6,7 @@
#include "compat/assert.hpp"
#include "compat/unreachable.hpp"
#include "src/tile-defs.hpp"
+#include <Corrade/Containers/StringStlView.h>
#include <filesystem>
#include <vector>
@@ -32,7 +33,10 @@ void tile_type::load_atlases()
}
std::shared_ptr<tile_atlas> tile_type::maybe_atlas(Containers::StringView str)
{
- auto it = _atlases.find(str);
+ auto it = std::find_if(_atlases.begin(), _atlases.end(), [&](const auto& tuple) -> bool {
+ const auto& [x, _] = tuple;
+ return Containers::StringView{x} == str;
+ });
if (it == _atlases.end())
return nullptr;
else