home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!gdt!aber!aberfa!pcg
- From: pcg@aber.ac.uk (Piercarlo Grandi)
- Newsgroups: comp.editors
- Subject: Re: Undo, unlimited file size and internal data structure ... how ?
- Message-ID: <PCG.92Jul27205630@aberdb.aber.ac.uk>
- Date: 27 Jul 92 20:56:30 GMT
- References: <NMOUAWAD.92Jul21203226@math.waterloo.edu>
- Sender: news@aber.ac.uk (USENET news service)
- Reply-To: pcg@aber.ac.uk (Piercarlo Grandi)
- Organization: Coleg Prifysgol Cymru
- Lines: 38
- In-Reply-To: nmouawad@waterloo.edu's message of 22 Jul 92 00: 32:26 GMT
- Nntp-Posting-Host: aberdb
-
- On 22 Jul 92 00:32:26 GMT, nmouawad@waterloo.edu (Naji Mouawad) said:
-
- nmouawad> Two features of Emacs amazes me: unlimited file size and undo.
-
- An approximate but fairly close description for GNU Emacs is:
-
- The entire file is kept in memory as a malloc(3)'ed *string*.
-
- When you insert, the right part of the string is shifted righwards.
-
- To avoid having to do this for every character inserted, the right part
- of the string is shifted by a some thousand bytes, not by just one byte.
-
- This creates a gap/bubble in the middle of the string, which is "moved"
- whenever the insertion point changes. When the gap is exhausted, the
- string is realloc(3)'ed to a larger size.
-
- Undo information is kept as a stream of string updates.
-
- The above structure is called 'buffer gap method'.
-
- nmouawad> The same goes with unlimited file sizes.
-
- Actually GNU Emacs does *not* support unlimited file sizes, it supports
- more or less unlimited _line_ sizes. Since it uses some bits in each
- pointer for tagging, usually the maximum string (and thus file) size for
- GNU Emacs is far smaller than the total address space, maybe as low as 8MB.
-
- nmouawad> What kink of internal representation is being used by Emacs in
- nmouawad> order to keep a fast response while managing big files ?
-
- The response is only fast if you have a very fast CPU and real memory is
- larger than the file size. Shifting around things is very bad for CPU
- efficiency and especially for paging efficiency.
- --
- Piercarlo Grandi | ARPA: pcg%uk.ac.aber@nsfnet-relay.ac.uk
- Dept of CS, UCW Aberystwyth | UUCP: ...!mcsun!ukc!aber-cs!pcg
- Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@aber.ac.uk
-