opt:replace vector push_back with emplace_back

This commit is contained in:
Xiao YiFang 2022-08-09 20:47:10 +08:00
parent c448f56f2b
commit 289beca884
2 changed files with 4 additions and 4 deletions

View file

@ -555,7 +555,7 @@ MdictParser::BlockInfoVector MdictParser::decodeHeadWordBlockInfo( QByteArray co
qint64 compressedSize = readNumber( s );
// headword block decompressed size
qint64 decompressedSize = readNumber( s );
headWordBlockInfos.push_back( BlockInfoVector::value_type( compressedSize, decompressedSize ) );
headWordBlockInfos.emplace_back(compressedSize, decompressedSize);
}
return headWordBlockInfos;
@ -588,7 +588,7 @@ MdictParser::HeadWordIndex MdictParser::splitHeadWordBlock( QByteArray const & b
}
p += headWordBuf.size();
QString headWord = toUtf16( encoding_, headWordBuf.constBegin(), headWordBuf.size() );
index.push_back( HeadWordIndex::value_type( headWordId, headWord ) );
index.emplace_back(headWordId, headWord);
}
return index;

4
mdx.cc
View file

@ -435,8 +435,8 @@ void MdxDictionary::doDeferredInit()
idx.read( &buf.front(), sz );
uint32_t btreeMaxElements = idx.read<uint32_t>();
uint32_t rootOffset = idx.read<uint32_t>();
mddFileNames.push_back( string( &buf.front() ) );
mddIndexInfos.push_back( IndexInfo( btreeMaxElements, rootOffset ) );
mddFileNames.emplace_back(&buf.front());
mddIndexInfos.emplace_back(btreeMaxElements, rootOffset);
}
vector< string > const dictFiles = getDictionaryFilenames();