mirror of https://github.com/odrling/Aegisub
Use a flat_map for the thesaurus index
This commit is contained in:
parent
d9a2669389
commit
6a193f280e
|
@ -35,7 +35,7 @@ namespace agi {
|
||||||
Thesaurus::Thesaurus(agi::fs::path const& dat_path, agi::fs::path const& idx_path)
|
Thesaurus::Thesaurus(agi::fs::path const& dat_path, agi::fs::path const& idx_path)
|
||||||
: dat(io::Open(dat_path))
|
: dat(io::Open(dat_path))
|
||||||
{
|
{
|
||||||
std::unique_ptr<std::ifstream> idx(io::Open(idx_path));
|
auto idx = io::Open(idx_path);
|
||||||
|
|
||||||
std::string encoding_name;
|
std::string encoding_name;
|
||||||
getline(*idx, 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);
|
getline(*idx, unused_entry_count);
|
||||||
|
|
||||||
// Read the list of words and file offsets for those words
|
// Read the list of words and file offsets for those words
|
||||||
for (line_iterator<std::string> iter(*idx, encoding_name), end; iter != end; ++iter) {
|
for (auto const& line : line_iterator<std::string>(*idx, encoding_name)) {
|
||||||
std::vector<std::string> chunks;
|
std::vector<std::string> chunks;
|
||||||
boost::split(chunks, *iter, _1 == '|');
|
boost::split(chunks, line, _1 == '|');
|
||||||
if (chunks.size() == 2)
|
if (chunks.size() == 2)
|
||||||
offsets[chunks[0]] = atoi(chunks[1].c_str());
|
offsets[chunks[0]] = atoi(chunks[1].c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
#include "fs_fwd.h"
|
#include "fs_fwd.h"
|
||||||
|
|
||||||
|
#include <boost/container/flat_map.hpp>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -30,7 +30,7 @@ namespace charset { class IconvWrapper; }
|
||||||
|
|
||||||
class Thesaurus {
|
class Thesaurus {
|
||||||
/// Map of word -> byte position in the data file
|
/// Map of word -> byte position in the data file
|
||||||
std::map<std::string, int> offsets;
|
boost::container::flat_map<std::string, int> offsets;
|
||||||
/// Read handle to the data file
|
/// Read handle to the data file
|
||||||
std::unique_ptr<std::istream> dat;
|
std::unique_ptr<std::istream> dat;
|
||||||
/// Converter from the data file's charset to UTF-8
|
/// Converter from the data file's charset to UTF-8
|
||||||
|
|
Loading…
Reference in New Issue