I need to efficiently edit large text documents (e.g. source code files) in javascript.
insertAtPosition(n, str)and deleteAtPosition(n, length)should be fast.
A naive line implementation is slow because each operation requires copying the contents of the document to a new line.
There are several effective ways to do this. I could use an array of strings ( Ace , since Bespin does this), but it will be slow when there are super long strings or many short strings. A better implementation would be to use skip lists or some other smart data structure.
But I would expect someone to have done this already.
Are there any libraries that already do this? I cannot find anything useful with Google - is there a common name for this problem?
source
share