Closed kjk closed 11 months ago
Even more memory-compact would be to have emojis as a single string. Since they are all single unicode characters, we can easily get the emoji from string by index.
There are 4700 emojis, which would be about 4700*2 (2 would be average byte count of emoji) i.e. 9400 bytes i.e. ~9 kB
In v8, a string overhead is ~40 bytes (https://stackoverflow.com/questions/45803829/memory-overhead-of-typed-arrays-vs-strings/45808835#45808835) which is ~184 kB.
emoji names could be stored as a single string (using e.g. space as a separator), saving another ~184 kB, but would make finding the emoji a bit harder. But not hard in absolute sense.
Definitely a nice to have. Not a big priority for me at the moment, but happy to take contributions :)
I hope it won't come off as rude but I've already did the work and you can steal it: https://github.com/kjk/noted/commit/92e3725f2bfe6f1458ea041dc7d98b5f78ad7f63
But this is in context of my own app which is not a fork of Silverbullet but is in part inspired by SB and uses the great work you did on extended Markdown in CodeMirror etc.
So I'm sharing some of the improvements I've made to the code in the form of high-level description and a pointer to my implementation but the code of my app diverged enough that I can't just re-apply my changes over SB code and I don't have the bandwidth to do more than that.
So to set the expectation: showing how I implemented this in my app is the best I can do.
Took me some time to get to this, but I did! And upgraded to a new (even larger) emoji set along the way. Thanks for the pointer!
There are 2 ways
plugs\emoji\emoji.js
could be optimized:emoji.json
could be a flat array instead of array of arraysemojiCompleter
creates 2 arrays (filteredEmoji
andoptions
) but could directly constructoptions
arrayI've implemented this in https://github.com/kjk/noted/commit/92e3725f2bfe6f1458ea041dc7d98b5f78ad7f63
Feel free to steal the code. Not that it's hard to write.