mirror of
https://github.com/open-goal/jak-project
synced 2026-09-08 03:46:51 -04:00
[goalc] Cleaned up speedups (#3066)
Started at 349,880,038 allocations and 42s - Switched to making `Symbol` in GOOS be a "fixed type", just a wrapper around a `const char*` pointing to the string in the symbol table. This is a step toward making a lot of things better, but by itself not a huge improvement. Some things may be worse due to more temp `std::string` allocations, but one day all these can be removed. On linux it saved allocations (347,685,429), and saved a second or two (41 s). - cache `#t` and `#f` in interpreter, better lookup for special forms/builtins (hashtable of pointers instead of strings, vector for the small special form list). Dropped time to 38s. - special-case in quasiquote when splicing is the last thing in a list. Allocation dropped to 340,603,082 - custom hash table for environment lookups (lexical vars). Dropped to 36s and 314,637,194 - less allocation in `read_list` 311,613,616. Time about the same. - `let` and `let*` in Interpreter.cpp 191,988,083, time down to 28s.
This commit is contained in:
@@ -54,7 +54,7 @@ Condition Compiler::compile_condition(const goos::Object& condition, Env* env, b
|
||||
auto fas = first.as_symbol();
|
||||
|
||||
// if there's a not, we can just try again to get an optimization with the invert flipped.
|
||||
if (fas->name == "not") {
|
||||
if (fas == "not") {
|
||||
if (!pair_cdr(rest).is_empty_list()) {
|
||||
throw_compiler_error(condition, "A condition with \"not\" can have only one argument");
|
||||
}
|
||||
@@ -62,7 +62,7 @@ Condition Compiler::compile_condition(const goos::Object& condition, Env* env, b
|
||||
}
|
||||
|
||||
auto& conditions = invert ? conditions_inverted : conditions_normal;
|
||||
auto nc_kv = conditions.find(fas->name);
|
||||
auto nc_kv = conditions.find(fas.name_ptr);
|
||||
|
||||
if (nc_kv != conditions.end()) {
|
||||
// it is an optimizable condition!
|
||||
@@ -290,7 +290,7 @@ Val* Compiler::compile_cond(const goos::Object& form, const goos::Object& rest,
|
||||
}
|
||||
|
||||
Val* Compiler::compile_and_or(const goos::Object& form, const goos::Object& rest, Env* env) {
|
||||
std::string op_name = form.as_pair()->car.as_symbol()->name;
|
||||
std::string op_name = form.as_pair()->car.as_symbol().name_ptr;
|
||||
bool is_and = false;
|
||||
if (op_name == "and") {
|
||||
is_and = true;
|
||||
|
||||
Reference in New Issue
Block a user