Haha, yeah using TypedArrays to flat pack data structures is so much fun Instead of {a: 6, b: 7, prev: 2, next: 0} we could store it as a quad in a Uint16Array as [6,7,2,0]. Iterating over items is done in jumps of 4. Index at 1, and terminate at 0 and we have minimal GC! :D
-
Show this thread
-
Replying to @yoshuawuyts
Y'all are reinventing writing asm-memory-handling and we have yet to invent C. Manually doing array offsets is not a nicely maintainable way of writing code :)
3 replies 0 retweets 0 likes -
Replying to @rikarends @yoshuawuyts
And i even think asm had named structs, but not entirely sure anymore. I'm currently working on compiling bridge-layer JS to get proper struct support in specialised methods.
1 reply 0 retweets 0 likes -
Replying to @rikarends @yoshuawuyts
Ideally however JS would get first-class struct types though.
1 reply 0 retweets 1 like -
Replying to @rikarends @yoshuawuyts
Btw i also write manual typed-array packing code, my new compiler communicates between threads with just a typed array i have to keep the 'struct' type of in my head. Its crap to maintain though.
2 replies 0 retweets 1 like -
Replying to @rikarends @yoshuawuyts
Subclass TypedArrays / DataView, https://jsfiddle.net/fqmacrgL/ , I would avoid WeakMap memoizing substructs, but once private fields land they won't suffer same problems
2 replies 0 retweets 1 like
Yay, thanks!
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.