Skip to content

Commit d45240f

Browse files
committedFeb 13, 2019
chore(table_translator): move collected dict entries to sentence translation
1 parent 0258c7f commit d45240f

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed
 

‎src/rime/gear/table_translator.cc

+16-16
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,9 @@ Spans SentenceSyllabifier::Syllabify(const Phrase* phrase) {
380380
class SentenceTranslation : public Translation {
381381
public:
382382
SentenceTranslation(TableTranslator* translator,
383-
an<Sentence> sentence,
384-
DictEntryCollector* collector,
385-
UserDictEntryCollector* ucollector,
383+
an<Sentence>&& sentence,
384+
DictEntryCollector&& collector,
385+
UserDictEntryCollector&& ucollector,
386386
const string& input,
387387
size_t start);
388388
virtual bool Next();
@@ -403,17 +403,17 @@ class SentenceTranslation : public Translation {
403403
};
404404

405405
SentenceTranslation::SentenceTranslation(TableTranslator* translator,
406-
an<Sentence> sentence,
407-
DictEntryCollector* collector,
408-
UserDictEntryCollector* ucollector,
406+
an<Sentence>&& sentence,
407+
DictEntryCollector&& collector,
408+
UserDictEntryCollector&& ucollector,
409409
const string& input,
410410
size_t start)
411-
: translator_(translator), input_(input), start_(start) {
412-
sentence_.swap(sentence);
413-
if (collector)
414-
collector_.swap(*collector);
415-
if (ucollector)
416-
user_phrase_collector_.swap(*ucollector);
411+
: translator_(translator),
412+
sentence_(std::move(sentence)),
413+
collector_(std::move(collector)),
414+
user_phrase_collector_(std::move(ucollector)),
415+
input_(input),
416+
start_(start) {
417417
PrepareSentence();
418418
CheckEmpty();
419419
}
@@ -634,17 +634,17 @@ TableTranslator::MakeSentence(const string& input, size_t start,
634634
// compare and update sentences
635635
if (sentences.find(end_pos) == sentences.end() ||
636636
sentences[end_pos]->weight() <= new_sentence->weight()) {
637-
sentences[end_pos] = new_sentence;
637+
sentences[end_pos] = std::move(new_sentence);
638638
}
639639
}
640640
}
641641
an<Translation> result;
642642
if (sentences.find(input.length()) != sentences.end()) {
643643
result = Cached<SentenceTranslation>(
644644
this,
645-
sentences[input.length()],
646-
include_prefix_phrases ? &collector : NULL,
647-
include_prefix_phrases ? &user_phrase_collector : NULL,
645+
std::move(sentences[input.length()]),
646+
include_prefix_phrases ? std::move(collector) : DictEntryCollector(),
647+
include_prefix_phrases ? std::move(user_phrase_collector) : UserDictEntryCollector(),
648648
input,
649649
start);
650650
if (result && filter_by_charset) {

0 commit comments

Comments
 (0)
Please sign in to comment.