Prevented NO-OP calls to the memory allocator

Also shaved off about 1-2 milliseconds of execution time of fib-memo.toy
This commit is contained in:
2023-02-26 21:20:22 +11:00
parent 1064b69d04
commit 624a0c80ba
7 changed files with 44 additions and 25 deletions

View File

@@ -18,8 +18,10 @@ void Toy_freeLiteralArray(Toy_LiteralArray* array) {
Toy_freeLiteral(array->literals[i]);
}
TOY_FREE_ARRAY(Toy_Literal, array->literals, array->capacity);
Toy_initLiteralArray(array);
if (array->capacity > 0) {
TOY_FREE_ARRAY(Toy_Literal, array->literals, array->capacity);
Toy_initLiteralArray(array);
}
}
int Toy_pushLiteralArray(Toy_LiteralArray* array, Toy_Literal literal) {