diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-10 21:27:08 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-10 22:17:43 +0100 |
| commit | ee1a527191db646850ee919b8fe3a6f8cb6cd693 (patch) | |
| tree | a1ff23b8c0f93d689d51d3837caefaa72b9480cd /editor | |
| parent | 0e23ba9e5a565e34fee0f024e29ce162f420ec22 (diff) | |
get rid of std::string
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/tile-editor.cpp | 17 | ||||
| -rw-r--r-- | editor/tile-editor.hpp | 5 |
2 files changed, 8 insertions, 14 deletions
diff --git a/editor/tile-editor.cpp b/editor/tile-editor.cpp index 2a0e9abc..f396d64a 100644 --- a/editor/tile-editor.cpp +++ b/editor/tile-editor.cpp @@ -6,7 +6,6 @@ #include "random.hpp" #include "serialize/json-helper.hpp" #include "serialize/tile-atlas.hpp" -#include <Corrade/Containers/StringStl.h> #include <Corrade/Utility/Path.h> namespace floormat { @@ -27,26 +26,22 @@ void tile_editor::load_atlases() if (auto x = name.findLast('.'); x) name = name.prefix(x.data()); auto& [_, vec] = _permutation; - vec.reserve((std::size_t)atlas->num_tiles()); - _atlases[name] = std::move(atlas); + vec.reserve(atlas->num_tiles()); + _atlases[name] = atlas; } } std::shared_ptr<tile_atlas> tile_editor::maybe_atlas(StringView str) { - auto it = std::find_if(_atlases.begin(), _atlases.end(), [&](const auto& tuple) -> bool { - const auto& [x, _] = tuple; - return StringView{x} == str; - }); - if (it == _atlases.end()) - return nullptr; - else + if (auto it = _atlases.find(str); it != _atlases.end()) return it->second; + else + return nullptr; } std::shared_ptr<tile_atlas> tile_editor::atlas(StringView str) { - if (auto ptr = maybe_atlas(str); ptr) + if (auto ptr = maybe_atlas(str)) return ptr; else fm_abort("no such atlas: %s", str.cbegin()); diff --git a/editor/tile-editor.hpp b/editor/tile-editor.hpp index 53b12e55..9f4bb2db 100644 --- a/editor/tile-editor.hpp +++ b/editor/tile-editor.hpp @@ -4,10 +4,9 @@ #include "src/tile-image.hpp" #include "global-coords.hpp" #include <vector> -#include <string> #include <map> #include <memory> -#include <Corrade/Containers/StringView.h> +#include <Corrade/Containers/String.h> namespace floormat { @@ -25,7 +24,7 @@ private: std::vector<decltype(tile_image_proto::variant)> variant; }; - std::string _name; + String _name; std::map<StringView, std::shared_ptr<tile_atlas>> _atlases; tile_image_proto _selected_tile; tuple _permutation; |
