istf-spec
istf-spec copied to clipboard
Optimization: use single array
Should we go for single array? As consequence we will only be able to express this:
- [MARKER]
- [MARKER, value]
Right now it seems to work nicely.
[
[RULE_START, 1],
[SELECTOR, 'body'],
[PROPERTY, 'color'],
[VALUE, 'red'],
[RULE_END]
]
will become
[
RULE_START, 1,
SELECTOR, 'body',
PROPERTY, 'color',
VALUE, 'red',
RULE_END
]
Should we also go for all string values? Benchmark shows a considerable perf benefit in v8, if it is not flowed: https://esbench.com/bench/592d599e99634800a03483d8
[
1, 1,
2, 'body',
3, 'color',
4, 'red',
5
]
will become
[
'1', '1',
'2', 'body',
'3', 'color',
'4', 'red',
'5'
]
- I am not sure if its worth it from the performance perspective (because only v8 and on micro level)
- Tested storage savings, using 100kb probe it shrinks down to 80kb => 20%, not sure if its worth. Probe was
[1,1,2,"body",3,"color",4,"red",5]=>1\n1\n\n2\n\nbody\n\n3\n\ncolor\n4\nred\n5 - We will need a separate array for fn refs or any other refs