mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Use a std::unordered_map for looking up sections by name (#1357)
This commit is contained in:
@@ -83,10 +83,8 @@ static uint32_t getSectIDIfAny(Section *sect) {
|
||||
if (!sect)
|
||||
return (uint32_t)-1;
|
||||
|
||||
for (auto it = sectionList.begin(); it != sectionList.end(); it++) {
|
||||
if (&*it == sect)
|
||||
return it - sectionList.begin();
|
||||
}
|
||||
if (auto search = sectionMap.find(sect->name); search != sectionMap.end())
|
||||
return (uint32_t)(sectionMap.size() - search->second - 1);
|
||||
|
||||
fatalerror("Unknown section '%s'\n", sect->name.c_str());
|
||||
}
|
||||
@@ -373,8 +371,8 @@ void out_WriteObject() {
|
||||
for (Symbol const *sym : objectSymbols)
|
||||
writesymbol(*sym, f);
|
||||
|
||||
for (Section § : sectionList)
|
||||
writesection(sect, f);
|
||||
for (auto it = sectionList.rbegin(); it != sectionList.rend(); it++)
|
||||
writesection(*it, f);
|
||||
|
||||
putlong(assertions.size(), f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user