From 2e72c24867e74b057915d2fbc203a72d44e2a7e3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 5 Dec 2022 06:31:28 +0100 Subject: loader: reserve the right size for anim atlas list --- loader/atlas.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'loader') diff --git a/loader/atlas.cpp b/loader/atlas.cpp index 1354e922..d39a0c40 100644 --- a/loader/atlas.cpp +++ b/loader/atlas.cpp @@ -84,13 +84,15 @@ std::shared_ptr loader_impl::anim_atlas(StringView name, StringView void loader_impl::get_anim_atlas_list() { anim_atlases.clear(); - anim_atlases.reserve(64); using f = Path::ListFlag; constexpr auto flags = f::SkipDirectories | f::SkipDotAndDotDot | f::SkipSpecial | f::SortAscending; if (const auto list = Path::list(ANIM_PATH, flags); list) + { + anim_atlases.reserve(list->size()*2); for (StringView str : *list) if (str.hasSuffix(".json")) anim_atlases.emplace_back(str.exceptSuffix(std::size(".json")-1)); + } } bool loader_impl::check_atlas_name(StringView str) -- cgit v1.2.3