
Brad Beveridge writes:
I've thought about the two methods (gap buffer vs linked list of lines), and basically the performance for either method is probably about the same for most operations.
Probably. However, a list of strings will have very bad performance if you want to edit code with very long lines. My intention for Climacs was to eventually use a tree of flexichains.
The one big place that a gapbuffer wins is when you want to treat a large section of the buffer as a read-only string. For a list of lines you need to cons up a new string, for a gap buffer (assuming it is locked), you simply need to move the gap and take a pointer into the gap buffer.
Sure.
I envision using this "large string" mode of the gap buffer for: - searching one huge string with CL-PPCRE - saving the buffer in one call
So after all my rambling I have two questions: 1) Is it appropriate to use Flexichain in this "one large string" manner? Obviously you don't want to always convert to this form, but it is handy for running a search on the buffer and some other uses.
I think it would work pretty well.
2) What is involved in creating a function that consolidates the data into a contiguous chunk that is suitable for creating a displaced array into?
Well, there is an additional complication. A Flexichain is circular, so its logical beginning could be in the middle of the physical array. Aside from that, you just have to move the gap to the right place, I would think. -- Robert Strandh --------------------------------------------------------------------- Greenspun's Tenth Rule of Programming: any sufficiently complicated C or Fortran program contains an ad hoc informally-specified bug-ridden slow implementation of half of Common Lisp. ---------------------------------------------------------------------