Use std::get_if instead of std::visit (#1367)

`std::visit` is (arguably) cleaner code, but older versions of gcc
and clang (not very old; the ones packaged with Ubuntu 22.04 LTS)
compile them as tables of function pointers, instead of efficient
jump tables.
This commit is contained in:
Sylvie
2024-03-20 22:37:54 -04:00
committed by GitHub
parent 035678d250
commit 0af1e512c2
10 changed files with 167 additions and 217 deletions

View File

@@ -564,7 +564,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) {
if (symbol.type == SYMTYPE_EXPORT)
sym_AddSymbol(symbol);
if (Label *label = std::get_if<Label>(&symbol.data); label)
if (auto *label = std::get_if<Label>(&symbol.data); label)
nbSymPerSect[label->sectionID]++;
}
@@ -603,7 +603,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) {
// Give symbols' section pointers to their sections
for (uint32_t i = 0; i < nbSymbols; i++) {
if (Label *label = std::get_if<Label>(&fileSymbols[i].data); label) {
if (auto *label = std::get_if<Label>(&fileSymbols[i].data); label) {
Section *section = fileSections[label->sectionID].get();
label->section = section;
@@ -620,7 +620,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) {
// This has to run **after** all the `sect_AddSection()` calls,
// so that `sect_GetSection()` will work
for (uint32_t i = 0; i < nbSymbols; i++) {
if (Label *label = std::get_if<Label>(&fileSymbols[i].data); label) {
if (auto *label = std::get_if<Label>(&fileSymbols[i].data); label) {
if (Section *section = label->section; section->modifier != SECTION_NORMAL) {
if (section->modifier == SECTION_FRAGMENT)
// Add the fragment's offset to the symbol's