Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-06

SynEdit and 'Gapped Buffer'

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Does SynEdit as used in Lazarus IDE use a gapped buffer to store it's text? I just read about 'gapped buffer' in the Java documentation and did some Googling to see what it is. A dynamic array is some sort of gapped buffer, but not optimized and the gap is always at the end of the array.

If SynEdit does use a gapped buffer, does FPC contain an implementation?

<Quote>
http://slashdot.org/developers/00/10/27/1516243.shtml NEdit stores text in a simple gapped-buffer structure, common to many text editors. The gapped-buffer is a block of memory with a moving hole in it. NEdit maintains the gap's size and continuously relocates it as part of the insertion / deletion process. This organization maps exceptionally well to how people actually use a text editor, and is very effective at minimizing the number and size of memory relocations that need to happen as users add and delete text. For comparison, another common approach to storage in a text editor is to break the text into linked blocks so that any given modification affects only a limited number of blocks. While this better limits worst-case memory movement; it also breaks up and scatters the stored data, destroying its locality; so the virtual memory system can't swap it as efficiently.
</Quote>

For more information see:

http://en.wikipedia.org/wiki/Gap_buffer
http://www.lazyhacker.com/gapbuffer/gapbuffer.htm

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Flávio Etrusco
to Graeme Geldenhuys

Yes and no. SynEdit simply uses a TStringList...

Best regards,
Fl?vio

Graeme Geldenhuys wrote 47 lines
Hi, Does SynEdit as used in Lazarus IDE use a gapped buffer to store it's text? I just read about 'gapped buffer' in the Java documentation and did some Googling to see what it is. A dynamic array is some sort of gapped buffer, but not optimized and the gap is always at the end of the array. If SynEdit does use a gapped buffer, does FPC contain an implementation? <Quote> http://slashdot.org/developers/00/10/27/1516243.shtml NEdit stores text in a simple gapped-buffer structure, common to many text editors. The gapped-buffer is a block of memory with a moving hole in it. NEdit maintains the gap's size and continuously relocates it as part of the insertion / deletion process. This organization maps exceptionally well to how people actually use a text editor, and is very effective at minimizing the number and size of memory relocations that need to happen as users add and delete text. For comparison, another common approach to storage in a text editor is to break the text into linked blocks so that any given modification affects only a limited number of blocks. While this better limits worst-case memory movement; it also breaks up and scatters the stored data, destroying its locality; so the virtual memory system can't swap it as efficiently. </Quote> For more information see: http://en.wikipedia.org/wiki/Gap_buffer http://www.lazyhacker.com/gapbuffer/gapbuffer.htm Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Mattias Gaertner
to Flávio Etrusco
Yes and no. SynEdit simply uses a TStringList...

It's not a TStringList, but a descendant of TStrings. And there is no gap buffer in the middle yet. This works good enough for a file with hundred thousand lines. There are many other bottlenecks that do a lot more work than the lines array.
Maybe a gap buffer could be useful, when there are millions of lines. But before that you must optimize many other parts.

Mattias

Show quoted text 58 lines
Best regards, Fl?vio On Wed, Jun 25, 2008 at 12:08 PM, Graeme Geldenhuys wrote: > Hi, > > Does SynEdit as used in Lazarus IDE use a gapped buffer to store > it's text? I just read about 'gapped buffer' in the Java > documentation and did some Googling to see what it is. A dynamic > array is some sort of gapped buffer, but not optimized and the gap > is always at the end of the array. > > If SynEdit does use a gapped buffer, does FPC contain an > implementation? > > > <Quote> > http://slashdot.org/developers/00/10/27/1516243.shtml > NEdit stores text in a simple gapped-buffer structure, common to > many text editors. The gapped-buffer is a block of memory with a > moving hole in it. NEdit maintains the gap's size and continuously > relocates it as part of the insertion / deletion process. This > organization maps exceptionally well to how people actually use a > text editor, and is very effective at minimizing the number and > size of memory relocations that need to happen as users add and > delete text. For comparison, another common approach to storage in > a text editor is to break the text into linked blocks so that any > given modification affects only a limited number of blocks. While > this better limits worst-case memory movement; it also breaks up > and scatters the stored data, destroying its locality; so the > virtual memory system can't swap it as efficiently. > </Quote> > > > For more information see: > > http://en.wikipedia.org/wiki/Gap_buffer > http://www.lazyhacker.com/gapbuffer/gapbuffer.htm > > > Regards, > - Graeme - > > > _______________________________________________ > fpGUI - a cross-platform Free Pascal GUI toolkit > http://opensoft.homeip.net/fpgui/ > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Mattias Gaertner
Show quoted text 12 lines
On Thu, Jun 26, 2008 at 7:02 AM, Mattias Gaertner wrote: > On Wed, 25 Jun 2008 13:26:20 -0300 > "Fl?vio Etrusco" wrote: > >> Yes and no. SynEdit simply uses a TStringList... > > It's not a TStringList, but a descendant of TStrings. > (...) But in this context it doesn't differ from a TStringList in any significant way...

A TStringList can not be easily extended to use a gap buffer. The synedit one can be extended. This might be significant if someone wants to implement a gap buffer.

Mattias

Reply by email