home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.editors
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!caen!umeecs!umn.edu!unet.umn.edu!fin
- From: fin@unet.umn.edu (Craig A. Finseth)
- Subject: Re: Q: Line # addressing using buffer gap.
- Message-ID: <1992Aug18.165508.10181@news2.cis.umn.edu>
- Keywords: Finseth, Craft, Of, Text, Editing, buffer, gap
- Sender: news@news2.cis.umn.edu (Usenet News Administration)
- Nntp-Posting-Host: norge.unet.umn.edu
- Organization: University of Minnesota, Networking Services.
- References: <1992Aug18.132755.25619@mks.com>
- Date: Tue, 18 Aug 1992 16:55:08 GMT
- Lines: 35
-
- In article <1992Aug18.132755.25619@mks.com>, 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.
- ...
- |> 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.
-
- Most buffer gap systems simply perform linear searches. Thus, to go
- to line X, the editor goes to the start of the buffer and searches
- past X-1 newlines.
-
- For most files on most systems, this is fast enough. Hence, no more
- hair is required.
-
- If you need faster performance, you can keep the list as you
- suggested, or you can track the current line number, updating it as
- you move past newlines. Marks can also record the line number (you
- would have to update or invalidate the line number part of marks after
- the point when changes were made).
-
- But all of this is hairy, and I would first find out if
- simple-and-straightforward is fast enough.
-
- What to do if it isn't fast enough will vary depending upon the
- characteristics of your system and the user's needs and expectations.
-
- Craig
-