@@ -225,21 +225,14 @@ void Client::Impl::Insert(const std::string& table_name, const Block& block) {
225225 RetryGuard ([this ]() { Ping (); });
226226 }
227227
228- std::vector<std::string> fields;
229- fields.reserve (block.GetColumnCount ());
230-
231- // Enumerate all fields
232- for (unsigned int i = 0 ; i < block.GetColumnCount (); i++) {
233- fields.push_back (NameToQueryString (block.GetColumnName (i)));
234- }
235-
236228 std::stringstream fields_section;
229+ const auto num_columns = block.GetColumnCount ();
237230
238- for (auto elem = fields. begin (); elem != fields. end () ; ++elem ) {
239- if (std::distance (elem, fields. end ()) == 1 ) {
240- fields_section << *elem ;
231+ for (unsigned int i = 0 ; i < num_columns ; ++i ) {
232+ if (i == num_columns - 1 ) {
233+ fields_section << NameToQueryString (block. GetColumnName (i)) ;
241234 } else {
242- fields_section << *elem << " ," ;
235+ fields_section << NameToQueryString (block. GetColumnName (i)) << " ," ;
243236 }
244237 }
245238
@@ -462,10 +455,9 @@ bool Client::Impl::ReadBlock(Block* block, CodedInputStream* input) {
462455 return false ;
463456 }
464457
458+ std::string name;
459+ std::string type;
465460 for (size_t i = 0 ; i < num_columns; ++i) {
466- std::string name;
467- std::string type;
468-
469461 if (!WireFormat::ReadString (input, &name)) {
470462 return false ;
471463 }
@@ -491,9 +483,7 @@ bool Client::Impl::ReceiveData() {
491483 Block block;
492484
493485 if (REVISION >= DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES) {
494- std::string table_name;
495-
496- if (!WireFormat::ReadString (&input_, &table_name)) {
486+ if (!WireFormat::SkipString (&input_)) {
497487 return false ;
498488 }
499489 }
0 commit comments