From 42eb513897a15f43edd719776af8ae52e6559170 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 23 Mar 2025 18:34:04 +0000 Subject: [PATCH] Codechange: Make use of emplace_back's return value. (#13879) --- src/game/game_text.cpp | 4 ++-- src/music/midifile.cpp | 4 ++-- src/saveload/linkgraph_sl.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/game/game_text.cpp b/src/game/game_text.cpp index ff337f5e44..a80c5b25ac 100644 --- a/src/game/game_text.cpp +++ b/src/game/game_text.cpp @@ -301,8 +301,8 @@ void GameStrings::Compile() translation_reader.ParseFile(); if (_errors != 0) throw std::exception(); - this->compiled_strings.emplace_back(p.language); - TranslationWriter writer(this->compiled_strings.back().lines); + auto &strings = this->compiled_strings.emplace_back(p.language); + TranslationWriter writer(strings.lines); writer.WriteLang(data); } } diff --git a/src/music/midifile.cpp b/src/music/midifile.cpp index e0dd6521f2..c246545563 100644 --- a/src/music/midifile.cpp +++ b/src/music/midifile.cpp @@ -786,8 +786,8 @@ struct MpsMachine { this->tempo_ticks = this->current_tempo; /* Always reset percussion channel to program 0 */ - this->target.blocks.push_back(MidiFile::DataBlock()); - AddMidiData(this->target.blocks.back(), MIDIST_PROGCHG + 9, 0x00); + auto &data_block = this->target.blocks.emplace_back(); + AddMidiData(data_block, MIDIST_PROGCHG + 9, 0x00); /* Technically should be an endless loop, but having * a maximum (about 10 minutes) avoids getting stuck, diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp index 9dfebbf899..793eaa1298 100644 --- a/src/saveload/linkgraph_sl.cpp +++ b/src/saveload/linkgraph_sl.cpp @@ -86,8 +86,8 @@ public: /* Edge data is now a simple vector and not any kind of matrix. */ size_t size = SlGetStructListLength(UINT16_MAX); for (size_t i = 0; i < size; i++) { - bn->edges.emplace_back(); - SlObject(&bn->edges.back(), this->GetLoadDescription()); + auto &edge = bn->edges.emplace_back(); + SlObject(&edge, this->GetLoadDescription()); } } }