From 706a72d5c1280f5c7ad6ea831e6c91580fb5b147 Mon Sep 17 00:00:00 2001
From: Thomas Goyne <plorkyeran@aegisub.org>
Date: Fri, 11 Jul 2014 16:03:20 -0700
Subject: [PATCH] Eliminate several memory allocations per line when reading
 thesaurus files

---
 libaegisub/common/thesaurus.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libaegisub/common/thesaurus.cpp b/libaegisub/common/thesaurus.cpp
index 7436e2178..fd006cd28 100644
--- a/libaegisub/common/thesaurus.cpp
+++ b/libaegisub/common/thesaurus.cpp
@@ -43,10 +43,9 @@ Thesaurus::Thesaurus(agi::fs::path const& dat_path, agi::fs::path const& idx_pat
 
 	// Read the list of words and file offsets for those words
 	for (auto const& line : line_iterator<std::string>(idx, encoding_name)) {
-		std::vector<std::string> chunks;
-		boost::split(chunks, line, [](char c) { return c == '|'; });
-		if (chunks.size() == 2)
-			offsets[chunks[0]] = static_cast<size_t>(atoi(chunks[1].c_str()));
+		auto pos = line.find('|');
+		if (pos != line.npos && line.find('|', pos + 1) == line.npos)
+			offsets[line.substr(0, pos)] = static_cast<size_t>(atoi(line.c_str() + pos + 1));
 	}
 }
 
-- 
GitLab