From 2eb8a266fd01bb0c6b57a40b16e1dc8ea927b522 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 20 Oct 2022 22:19:35 +0200 Subject: editor: avoid allocating std::string --- main/editor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 #include #include @@ -32,7 +33,10 @@ void tile_type::load_atlases() } std::shared_ptr 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 -- cgit v1.2.3