mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Massive dict copying optimisation, read more
I simply pre-allocated the new dict to the right size. This skips internal copying logic which was repeated on every expansion. This Should increase scope copying as well. I applied the same logic to arrays, but the increase in speed was tiny.
This commit is contained in:
16
scripts/test_copy_speed.toy
Normal file
16
scripts/test_copy_speed.toy
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
fn identity(x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
var dict: [int:int] = [:];
|
||||
|
||||
for (var i: int = 0; i < 1000; i++) {
|
||||
dict[i] = i;
|
||||
}
|
||||
|
||||
for (var i: int = 0; i < 100_000; i++) {
|
||||
var x = identity(dict);
|
||||
}
|
||||
Reference in New Issue
Block a user