nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] Rewriting to use an efficient data structure


From: David Benbennick
Subject: [Nano-devel] Rewriting to use an efficient data structure
Date: Sun, 11 Dec 2005 19:56:47 -0500

One problem with Nano is that it uses an inefficient data structure (a
linked list of char*) to store the buffer.  So typing a character at
the beginning of a line, for example, takes time proportional to the
length of the line.  Going to line  n  takes time proportional to n. 
If you try to use Nano to edit very large files, it easily gets bogged
down.

There are fancy data structures that allow all operations to be done
efficiently.  I've started a project to reimplement Nano using a
"text" data structure.  It's currently usable as an editor (just
barely!), but a lot of features haven't been done yet.  The code is at
http://www.cam.cornell.edu/~dbenbenn/new-nano.tar.gz

One benefit of using the "text" data structure is that it will be very
easy to implement the undo feature.  Another benefit is that many
operations are much easier.  Compare TextBuffer.cc:do_delete (12
lines) in the new version to text.c:do_delete (83 lines) in Nano's
current code.

David R: Is changing to C++ and using a fancy data structure something
you'd be willing to consider?

Any comments / patches to the code are welcome!  (Bug reports are
probably not very useful, since many features in this 0.0.1alpha
version simply haven't been implemented yet.)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]