Skip to content

Commit e7a5230

Browse files
ShaurenOvahlord
authored andcommitted
Tools/Map extractor: Minor optimization in MCNK parsing loop - look up end iterator once
1 parent 2e19198 commit e7a5230

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/tools/map_extractor/System.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "Common.h"
3030
#include "MapDefines.h"
31+
#include "IteratorPair.h"
3132
#include "StringFormat.h"
3233
#include "Util.h"
3334
#ifdef PLATFORM_WINDOWS
@@ -484,9 +485,9 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
484485
bool hasHoles = false;
485486
bool hasFlightBox = false;
486487

487-
for (std::multimap<std::string, FileChunk*>::const_iterator itr = adt.chunks.lower_bound("MCNK"); itr != adt.chunks.upper_bound("MCNK"); ++itr)
488+
for (auto const& [_, rawChunk] : Trinity::Containers::MapEqualRange(adt.chunks, "MCNK"))
488489
{
489-
adt_MCNK* mcnk = itr->second->As<adt_MCNK>();
490+
adt_MCNK* mcnk = rawChunk->As<adt_MCNK>();
490491

491492
// Area data
492493
area_ids[mcnk->iy][mcnk->ix] = mcnk->areaid;
@@ -531,7 +532,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
531532
}
532533

533534
// Get custom height
534-
if (FileChunk* chunk = itr->second->GetSubChunk("MCVT"))
535+
if (FileChunk* chunk = rawChunk->GetSubChunk("MCVT"))
535536
{
536537
adt_MCVT* mcvt = chunk->As<adt_MCVT>();
537538
// get V9 height map
@@ -560,7 +561,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
560561
// Liquid data
561562
if (mcnk->sizeMCLQ > 8)
562563
{
563-
if (FileChunk* chunk = itr->second->GetSubChunk("MCLQ"))
564+
if (FileChunk* chunk = rawChunk->GetSubChunk("MCLQ"))
564565
{
565566
adt_MCLQ* liquid = chunk->As<adt_MCLQ>();
566567
int count = 0;

0 commit comments

Comments
 (0)