4 ms·
I'm making a code editor and chose a grid: two dimensional array, And a string. Then it can cross check the string and array to see if there is a bug somewhere.
by z3t4 11y ago
I'm making a code editor and chose a grid: two dimensional array, And a string. Then it can cross check the string and array to see if there is a bug somewhere. This is of course not efficient, but it keeps me sane.
The grid also makes it easy to render the text.
- afandian 11y agoIs that a standard immutable string? Does this mean allocating a whole new string every time a character edit is made?
- z3t4 11y agoYes, thanks god for the garbage collector. Although this is JavaScript so I see it as a mutable string.
- afandian 11y agoI don't understand? Strings in JS are immutable. There's no way to mutate them. Using strings like this will thrash your garbage collection, especially with long lines. An array, or more interesting data structure, might be more sensible. (only pursuing this because I'm interested in your project!)
- z3t4 11y agoSorry, I keep mixing up variables with types. I do not think about types when I program (JavaScript). You might find my blog interesting: http://webtigerteam.com/johan/en/blog/editor2.htm http://webtigerteam.com/johan/en/blog/editor2.htm http://webtigerteam.com/johan/en/blog/editor.htm http://webtigerteam.com/johan/en/blog/editor.htm
- ant6n 11y agoSurely not one allocation per key, that could be up to like 10 allocations per second.