From 6a193f280e98ec8e48f90c3a0ae24df9a2f04a34 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 20 Dec 2013 09:18:24 -0800 Subject: [PATCH] Use a flat_map for the thesaurus index --- aegisub/libaegisub/common/thesaurus.cpp | 6 +++--- aegisub/libaegisub/include/libaegisub/thesaurus.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aegisub/libaegisub/common/thesaurus.cpp b/aegisub/libaegisub/common/thesaurus.cpp index 8767eb83d..15921fa17 100644 --- a/aegisub/libaegisub/common/thesaurus.cpp +++ b/aegisub/libaegisub/common/thesaurus.cpp @@ -35,7 +35,7 @@ namespace agi { Thesaurus::Thesaurus(agi::fs::path const& dat_path, agi::fs::path const& idx_path) : dat(io::Open(dat_path)) { - std::unique_ptr idx(io::Open(idx_path)); + auto idx = io::Open(idx_path); std::string encoding_name; getline(*idx, encoding_name); @@ -43,9 +43,9 @@ Thesaurus::Thesaurus(agi::fs::path const& dat_path, agi::fs::path const& idx_pat getline(*idx, unused_entry_count); // Read the list of words and file offsets for those words - for (line_iterator iter(*idx, encoding_name), end; iter != end; ++iter) { + for (auto const& line : line_iterator(*idx, encoding_name)) { std::vector chunks; - boost::split(chunks, *iter, _1 == '|'); + boost::split(chunks, line, _1 == '|'); if (chunks.size() == 2) offsets[chunks[0]] = atoi(chunks[1].c_str()); } diff --git a/aegisub/libaegisub/include/libaegisub/thesaurus.h b/aegisub/libaegisub/include/libaegisub/thesaurus.h index 5bdded31e..5e889a2be 100644 --- a/aegisub/libaegisub/include/libaegisub/thesaurus.h +++ b/aegisub/libaegisub/include/libaegisub/thesaurus.h @@ -18,8 +18,8 @@ #include "fs_fwd.h" +#include #include -#include #include #include #include @@ -30,7 +30,7 @@ namespace charset { class IconvWrapper; } class Thesaurus { /// Map of word -> byte position in the data file - std::map offsets; + boost::container::flat_map offsets; /// Read handle to the data file std::unique_ptr dat; /// Converter from the data file's charset to UTF-8