Re:Ask HN: What are some cool but obscure data structures yo...
by cmpolis on Friday July 22, 2022 @11:44AM
(#32193217)
this is a great way to store structured data in js since it saves the memory cost having repeated keys. e.g.:
[ Parent
| on HN ]
Re:Ask HN: What are some cool but obscure data structures yo...
by hayley-patton on Friday July 22, 2022 @08:06PM
(#32198689)
Decent JS engines will use "hidden classes" to dedupe keys for you already, so this isn't necessary to save space; the technique is pretty old and dates to Self. Still, the arrangement may help with locality of reference.
Re:Ask HN: What are some cool but obscure data structures yo...
by dan-robertson on Saturday July 23, 2022 @04:26AM
(#32201455)
In practice, most js engines these days can ‘recognise’ the ‘class’ of these objects (if you create them from scratch in a few places) and the memory representation would end up with a word for the ‘class’ which says that time is at field 0 and price at 1 and volume at 2, and then the data itself. The main reason is to speed up code that reads the fields rather than memory use.