home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / editors / 1829 < prev    next >
Encoding:
Internet Message Format  |  1992-07-27  |  2.2 KB

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