Skip to content

Commit

Permalink
chore(table_translator): move collected dict entries to sentence tran…
Browse files Browse the repository at this point in the history
…slation
  • Loading branch information
lotem committed Feb 13, 2019
1 parent 0258c7f commit d45240f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/rime/gear/table_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,9 @@ Spans SentenceSyllabifier::Syllabify(const Phrase* phrase) {
class SentenceTranslation : public Translation {
public:
SentenceTranslation(TableTranslator* translator,
an<Sentence> sentence,
DictEntryCollector* collector,
UserDictEntryCollector* ucollector,
an<Sentence>&& sentence,
DictEntryCollector&& collector,
UserDictEntryCollector&& ucollector,
const string& input,
size_t start);
virtual bool Next();
Expand All @@ -403,17 +403,17 @@ class SentenceTranslation : public Translation {
};

SentenceTranslation::SentenceTranslation(TableTranslator* translator,
an<Sentence> sentence,
DictEntryCollector* collector,
UserDictEntryCollector* ucollector,
an<Sentence>&& sentence,
DictEntryCollector&& collector,
UserDictEntryCollector&& ucollector,
const string& input,
size_t start)
: translator_(translator), input_(input), start_(start) {
sentence_.swap(sentence);
if (collector)
collector_.swap(*collector);
if (ucollector)
user_phrase_collector_.swap(*ucollector);
: translator_(translator),
sentence_(std::move(sentence)),
collector_(std::move(collector)),
user_phrase_collector_(std::move(ucollector)),
input_(input),
start_(start) {
PrepareSentence();
CheckEmpty();
}
Expand Down Expand Up @@ -634,17 +634,17 @@ TableTranslator::MakeSentence(const string& input, size_t start,
// compare and update sentences
if (sentences.find(end_pos) == sentences.end() ||
sentences[end_pos]->weight() <= new_sentence->weight()) {
sentences[end_pos] = new_sentence;
sentences[end_pos] = std::move(new_sentence);
}
}
}
an<Translation> result;
if (sentences.find(input.length()) != sentences.end()) {
result = Cached<SentenceTranslation>(
this,
sentences[input.length()],
include_prefix_phrases ? &collector : NULL,
include_prefix_phrases ? &user_phrase_collector : NULL,
std::move(sentences[input.length()]),
include_prefix_phrases ? std::move(collector) : DictEntryCollector(),
include_prefix_phrases ? std::move(user_phrase_collector) : UserDictEntryCollector(),
input,
start);
if (result && filter_by_charset) {
Expand Down

0 comments on commit d45240f

Please sign in to comment.