Commit Graph

13 Commits

Author SHA1 Message Date
52cb5f9456 Improved Rope's text insertion performance for large insertion strings. 2015-02-21 11:16:21 -08:00
a37bc17289 Even further improved balance unit tests.
Now the ropes are directly checked for adhering to the AVL balance
invariants.
2015-02-19 23:39:24 -08:00
b3ba8acdf5 Significantly improved Rope::rebalance() unit tests.
Now they directly run rebalance() on hand-constructed trees that test
various situations.
2015-02-19 23:23:36 -08:00
fe0a7e48ca Fixed bug in Rope::new_from_str().
The stragglers appended at the end were being appended at the top of
the tree, making it very unbalanced.  Using proper appending now.
2015-02-19 22:52:21 -08:00
2df1302723 Fixed bug in Rope::rebalance(). Stats weren't updated after rebalance. 2015-02-19 22:46:30 -08:00
5500c845f5 Ropes can now generate graphviz of their tree. Useful for debugging. 2015-02-19 22:39:57 -08:00
de668c5ddf Improved Rope::append()
Append no longer depends on a performant rebalance() operation in any
cases.  Append is guaranteed O(log N) now.
2015-02-18 23:41:28 -08:00
d95161b88f Improved Rope::rebalance() to actually rebalance properly in non-AVL cases.
The prior version worked fine for the typical single insertion/removal
cases.  But when larger imbalances happened due to bulk insertion or
removal it wouldn't work correctly.

The new improved version works on any tree whose children are themselves
balanced, even if they are extremely different heights when compared to
each other.  It works in O(log N) time.
2015-02-18 23:11:10 -08:00
535f219c41 Improved algorithm of Rope::append()
It doesn't use an intermediate conversion to a string anymore, and should
execute in O(log N) as long as the right-hand rope is equal length or
smaller than the left.

It may also be O(log N) for the left-hand rope being smaller, but that
depends on whether the rebalance code executes in O(log N) time when
the left and right hand side are individually balanced.  I haven't
analysed it yet, so dunno.
2015-02-17 23:10:38 -08:00
6eed3fcc74 Improved file load times.
There was a regression after switching to ropes.  Now it's pretty much
back to pre-rope load times.
2015-02-15 20:15:19 -08:00
de58f01b2f Added some benchmarks for Rope, and improved new_from_str() for Rope.
The new new_from_str() uses an algorithm that should be linear time
complexity compared to the length of the string.
2015-02-15 19:42:07 -08:00
e1c9a6955d Lines now internally use ropes to store their text.
The rope uses a large leaf-node text length, so in the vast majority of
cases this ends up being the same as directly storing the string data.
But in the case that the line becomes extremely long, this will allow
for reasonable performance
2015-02-15 14:56:56 -08:00
a89e505fb0 Beginnings of a Rope data structure for strings.
This will be used to hold the text of an individual line, for better
long-line handling.
2015-02-14 14:19:46 -08:00