mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Let's use this new emplace_back() thing. (#13081)
parent
98c8445519
commit
14e2839087
|
@ -182,8 +182,7 @@ bool DLSFile::ReadDLSArticulation(FileHandle &f, DWORD list_length, std::vector<
|
|||
|
||||
bool DLSFile::ReadDLSRegion(FileHandle &f, DWORD list_length, std::vector<DLSRegion> &out)
|
||||
{
|
||||
out.push_back(DLSRegion());
|
||||
DLSRegion ®ion = out.back();
|
||||
DLSRegion ®ion = out.emplace_back();
|
||||
|
||||
/* Set default values. */
|
||||
region.wave_sample.cbSize = 0;
|
||||
|
@ -267,8 +266,7 @@ bool DLSFile::ReadDLSRegionList(FileHandle &f, DWORD list_length, DLSInstrument
|
|||
|
||||
bool DLSFile::ReadDLSInstrument(FileHandle &f, DWORD list_length)
|
||||
{
|
||||
this->instruments.push_back(DLSInstrument());
|
||||
DLSInstrument &instrument = this->instruments.back();
|
||||
DLSInstrument &instrument = this->instruments.emplace_back();
|
||||
|
||||
while (list_length > 0) {
|
||||
ChunkHeader chunk;
|
||||
|
@ -339,8 +337,7 @@ bool DLSFile::ReadDLSInstrumentList(FileHandle &f, DWORD list_length)
|
|||
|
||||
bool DLSFile::ReadDLSWave(FileHandle &f, DWORD list_length, long offset)
|
||||
{
|
||||
this->waves.push_back(DLSWave());
|
||||
DLSWave &wave = this->waves.back();
|
||||
DLSWave &wave = this->waves.emplace_back();
|
||||
|
||||
/* Set default values. */
|
||||
MemSetT(&wave.wave_sample, 0);
|
||||
|
|
|
@ -210,8 +210,7 @@ static bool ReadTrackChunk(FileHandle &file, MidiFile &target)
|
|||
return false;
|
||||
}
|
||||
|
||||
target.blocks.push_back(MidiFile::DataBlock());
|
||||
MidiFile::DataBlock *block = &target.blocks.back();
|
||||
MidiFile::DataBlock *block = &target.blocks.emplace_back();
|
||||
|
||||
uint8_t last_status = 0;
|
||||
bool running_sysex = false;
|
||||
|
@ -222,8 +221,7 @@ static bool ReadTrackChunk(FileHandle &file, MidiFile &target)
|
|||
return false;
|
||||
}
|
||||
if (deltatime > 0) {
|
||||
target.blocks.push_back(MidiFile::DataBlock(block->ticktime + deltatime));
|
||||
block = &target.blocks.back();
|
||||
block = &target.blocks.emplace_back(block->ticktime + deltatime);
|
||||
}
|
||||
|
||||
/* Read status byte */
|
||||
|
@ -792,8 +790,7 @@ struct MpsMachine {
|
|||
* a maximum (about 10 minutes) avoids getting stuck,
|
||||
* in case of corrupted data. */
|
||||
for (uint32_t tick = 0; tick < 100000; tick += 1) {
|
||||
this->target.blocks.push_back(MidiFile::DataBlock());
|
||||
auto &block = this->target.blocks.back();
|
||||
auto &block = this->target.blocks.emplace_back();
|
||||
block.ticktime = tick;
|
||||
if (!this->PlayFrame(block)) {
|
||||
break;
|
||||
|
|
|
@ -3606,8 +3606,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop,
|
|||
definition_size = UINT32_MAX;
|
||||
}
|
||||
|
||||
layout.push_back(IndustryTileLayoutTile{});
|
||||
IndustryTileLayoutTile &it = layout.back();
|
||||
IndustryTileLayoutTile &it = layout.emplace_back();
|
||||
|
||||
it.ti.x = buf.ReadByte(); // Offsets from northermost tile
|
||||
++bytes_read;
|
||||
|
|
|
@ -77,8 +77,8 @@ public:
|
|||
|
||||
/* Build edge list from edge matrix. */
|
||||
for (NodeID to = edges[_linkgraph_from].dest_node; to != INVALID_NODE; to = edges[to].dest_node) {
|
||||
bn->edges.push_back(edges[to]);
|
||||
bn->edges.back().dest_node = to;
|
||||
auto &edge = bn->edges.emplace_back(edges[to]);
|
||||
edge.dest_node = to;
|
||||
}
|
||||
/* Sort by destination. */
|
||||
std::sort(bn->edges.begin(), bn->edges.end());
|
||||
|
|
Loading…
Reference in New Issue