home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.editors
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!mips!darwin.sura.net!zaphod.mps.ohio-state.edu!think.com!news.bbn.com!noc.near.net!wpi.WPI.EDU!rcarter
- From: rcarter@wpi.WPI.EDU (Randolph Carter <Joseph H. Allen>)
- Subject: Re: Q: Line # addressing using buffer gap.
- Message-ID: <Bt8o8E.A5q@wpi.WPI.EDU>
- Keywords: Finseth, Craft, Of, Text, Editing, buffer, gap
- Sender: news@wpi.WPI.EDU (USENET News System)
- Nntp-Posting-Host: wpi.wpi.edu
- Organization: Worcester Polytechnic Institute
- References: <1992Aug18.132755.25619@mks.com>
- Date: Wed, 19 Aug 1992 16:24:14 GMT
- Lines: 53
-
- ant@mks.com (Anthony Howe) writes:
- >
- >Is there a reasonably fast technique, given a Buffer Gap structure,
- >for finding line number X. Currently, AE, just performs linear scans
- >for <newline> marks when performing cursor motion, since the
- >assumption is that the majority of movement is localized.
-
- Here's a cute idea: change the LFs to CR-LF sequences. Then you only need
- to look at each other character to find the line ends and the search is
- twice as fast.
-
- Or change the lines to <length><chars> sequences. Perhaps make <length>
- variable length so it doesn't waste so much space. The search is then, say,
- 30 times as fast.
-
- >Being able to find the start of a line quickly would help in
- >implementing a Goto-Line command and possibly a better screen update
- >manager.
-
- I've found that the linear search is not so bad for the Goto-Line command,
- but maybe if your going to add the full set of vi commands it will become
- more important.
-
- I don't know how your screen update/generation algorithm works, but you can
- probably eliminate having to do a full screen generation on the simplest,
- but most often used commands. For example, prevent a full screen generation
- when you type in characters and when you backspace. When I added this to
- joe, it changed the amount of CPU time it used from being close to that for
- emacs to close to that for vi (and emacs does this optimization as well).
- Also a hint with curses: if you make a one character change on one place on
- the screen then curses does almost no work. But if you make a one character
- change on two places then curses checks all the characters between those two
- places.
-
- >I think I read somewhere about the idea of keeping a table of buffer
- >indexes that correspond to each line. Then as you insert or delete
- >characters in a given line, all the indexes above line X would need to
- >be updated. This idea strikes me as being very ugly since the time to
- >update the indexes is dependant on which line you are currently at.
- >If you were at the end of the file, this would be very quick, but if
- >you were at the beginning of the file, this time maybe unacceptable
- >for large files.
-
- Don't store the line addresses, store the line lengths in the buffer. This
- way you don't have to update anything (but you still have to read through
- the buffer sequencially to accumulate the line address). Actually you could
- store the line lengths in a buffer gap and maintain both at the same time,
- I.E., to eliminate copying in the table when you insert or delete a line.
- --
- /* rcarter@wpi.wpi.edu */ /* Amazing */ /* Joseph H. Allen */
- int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
- +r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
- ]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}
-