mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
opt:replace std::vector push_back with emplace_back
This commit is contained in:
parent
74c0da034b
commit
c448f56f2b
|
@ -835,7 +835,7 @@ vector< WordArticleLink > BtreeIndex::readChain( char const * & ptr )
|
||||||
|
|
||||||
ptr += sizeof( uint32_t );
|
ptr += sizeof( uint32_t );
|
||||||
|
|
||||||
result.push_back( WordArticleLink( str, articleOffset, prefix ) );
|
result.emplace_back(str, articleOffset, prefix);
|
||||||
|
|
||||||
if ( chainSize < str.size() + 1 + prefix.size() + 1 + sizeof( uint32_t ) )
|
if ( chainSize < str.size() + 1 + prefix.size() + 1 + sizeof( uint32_t ) )
|
||||||
throw exCorruptedChainData();
|
throw exCorruptedChainData();
|
||||||
|
@ -1100,7 +1100,7 @@ void IndexedWords::addWord( wstring const & word, uint32_t articleOffset, unsign
|
||||||
|
|
||||||
string utfWord=Utf8::encode( wstring(wordBegin, wordSize )) ;
|
string utfWord=Utf8::encode( wstring(wordBegin, wordSize )) ;
|
||||||
string utfPrefix;
|
string utfPrefix;
|
||||||
i->second.push_back( WordArticleLink( utfWord, articleOffset, utfPrefix ) );
|
i->second.emplace_back(utfWord, articleOffset, utfPrefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1121,7 +1121,7 @@ void IndexedWords::addWord( wstring const & word, uint32_t articleOffset, unsign
|
||||||
|
|
||||||
string utfPrefix = Utf8::encode( wstring( wordBegin, nextChar - wordBegin ) );
|
string utfPrefix = Utf8::encode( wstring( wordBegin, nextChar - wordBegin ) );
|
||||||
|
|
||||||
i->second.push_back( WordArticleLink( utfWord, articleOffset, utfPrefix ) );
|
i->second.emplace_back(utfWord, articleOffset, utfPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
wordsAdded += 1;
|
wordsAdded += 1;
|
||||||
|
@ -1143,8 +1143,7 @@ void IndexedWords::addSingleWord( wstring const & word, uint32_t articleOffset )
|
||||||
wstring folded = Folding::apply( word );
|
wstring folded = Folding::apply( word );
|
||||||
if( folded.empty() )
|
if( folded.empty() )
|
||||||
folded = Folding::applyWhitespaceOnly( word );
|
folded = Folding::applyWhitespaceOnly( word );
|
||||||
operator []( Utf8::encode( folded ) ).push_back(
|
operator []( Utf8::encode( folded ) ).emplace_back(Utf8::encode( word ), articleOffset);
|
||||||
WordArticleLink( Utf8::encode( word ), articleOffset ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexInfo buildIndex( IndexedWords const & indexedWords, File::Class & file )
|
IndexInfo buildIndex( IndexedWords const & indexedWords, File::Class & file )
|
||||||
|
|
Loading…
Reference in a new issue