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

@@ -27,8 +27,8 @@ Label const &Symbol::label() const {
void sym_AddSymbol(Symbol &symbol) {
Symbol *other = sym_GetSymbol(symbol.name);
int32_t const *symValue = std::get_if<int32_t>(&symbol.data);
int32_t const *otherValue = other ? std::get_if<int32_t>(&other->data) : nullptr;
auto *symValue = std::get_if<int32_t>(&symbol.data);
auto *otherValue = other ? std::get_if<int32_t>(&other->data) : nullptr;
// Check if the symbol already exists with a different value
if (other && !(symValue && otherValue && *symValue == *otherValue)) {