From 289beca884e58585175ec297446458e4132f1216 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Tue, 9 Aug 2022 20:47:10 +0800 Subject: [PATCH] opt:replace vector push_back with emplace_back --- mdictparser.cc | 4 ++-- mdx.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mdictparser.cc b/mdictparser.cc index 931a8fff..952d3735 100644 --- a/mdictparser.cc +++ b/mdictparser.cc @@ -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; diff --git a/mdx.cc b/mdx.cc index f720a3cc..70de1524 100644 --- a/mdx.cc +++ b/mdx.cc @@ -435,8 +435,8 @@ void MdxDictionary::doDeferredInit() idx.read( &buf.front(), sz ); uint32_t btreeMaxElements = idx.read(); uint32_t rootOffset = idx.read(); - 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();