1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-03 05:32:13 +00:00

LibJS: Use macros to enumerate well-known symbols

Not only is this a much nicer api (can't pass a typo'd string into the
get_well_known_symbol function), it is also a bit more performant since
there are no hashmap lookups.
This commit is contained in:
Matthew Olsson 2020-07-09 15:34:20 -07:00 committed by Andreas Kling
parent 2ea85355fe
commit c485c86015
7 changed files with 42 additions and 31 deletions

View file

@ -46,8 +46,10 @@ void SymbolConstructor::initialize(Interpreter& interpreter, GlobalObject& globa
define_native_function("for", for_, 1, Attribute::Writable | Attribute::Configurable);
define_native_function("keyFor", key_for, 1, Attribute::Writable | Attribute::Configurable);
for (auto& entry : interpreter.get_well_known_symbol_map({}))
define_property(entry.key, entry.value, 0);
#define __JS_ENUMERATE(SymbolName, snake_name) \
define_property(#SymbolName, interpreter.well_known_symbol_##snake_name(), 0);
JS_ENUMERATE_WELL_KNOWN_SYMBOLS
#undef __JS_ENUMERATE
}
SymbolConstructor::~SymbolConstructor()