summaryrefslogtreecommitdiff
path: root/extractor/vocabulary.cc
diff options
context:
space:
mode:
authorPaul Baltescu <pauldb89@gmail.com>2013-11-24 13:19:28 +0000
committerPaul Baltescu <pauldb89@gmail.com>2013-11-25 17:54:09 +0000
commit3973a7e4a8302b4a02fee7d2950bb469b37e2452 (patch)
tree8e76b5492648aa95bab6ecc915dd35e7514c1c07 /extractor/vocabulary.cc
parent79206291f78fba893fda6a61ff0ae9264d00bb82 (diff)
Reduce memory overhead for constructing the intersector.
Diffstat (limited to 'extractor/vocabulary.cc')
-rw-r--r--extractor/vocabulary.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/extractor/vocabulary.cc b/extractor/vocabulary.cc
index 15795d1e..aef674a5 100644
--- a/extractor/vocabulary.cc
+++ b/extractor/vocabulary.cc
@@ -8,12 +8,13 @@ int Vocabulary::GetTerminalIndex(const string& word) {
int word_id = -1;
#pragma omp critical (vocabulary)
{
- if (!dictionary.count(word)) {
+ auto it = dictionary.find(word);
+ if (it != dictionary.end()) {
+ word_id = it->second;
+ } else {
word_id = words.size();
dictionary[word] = word_id;
words.push_back(word);
- } else {
- word_id = dictionary[word];
}
}
return word_id;