- Subject: Re: [jed-users] del_region() tremendously slow
- From: "John E. Davis" <jed@xxxxxxxxxxx>
- Date: Mon, 27 Jan 2025 23:21:21 -0500
Morten Bo Johansen <mbj@xxxxxxxxx> wrote:
> I just happened to stumble into this rather abnormal use case: mark and
> delete about two million lines in a file. With del_region(), it takes about
> 8 seconds to do so on my oldish computer. With the competition (Emacs), it
> happens in the blink of an eye. Why is del_region() so slow?
I rewrote the delete_region function to improve its peformance.
Testing shows that it is now about 150 times faster than before. The
updated version is pre0.99.20-188, which you can find at
<http://snapshots.jedsoft.org/snapshots/>. (I will update the github
repository next week with the recent updates; until then use the
tarfile or <git://git.jedsoft.org/git/jed.git>)
Emacs and jed have very different representations of a buffer. Jed
represents a buffer as a linked list of lines, whereas Emacs uses a
simple character buffer with a gap where insertions/deletions take
place. Each has its advantages and disadvantages. Deleting a region
using the buffer gap approach is a trivial operation that simply
involves updating the size of the gap (assuming the gap does not have
to be moved).
Thanks for reporting this.
--John
>
> The following function does the job in 1 sec flat - still slower than
> Emacs, but 8 times faster than del_region():
>
> define delete_region()
> {
> variable reg_end;
>
> ifnot (is_visible_mark)
> return flush("no region is marked");
>
> check_region(1);
> reg_end = what_line;
> exchange_point_and_mark();
>
> loop (reg_end - what_line())
> delete_line();
>
> pop_spot(); pop_mark_0();
> }
>
> If this function doesn't deviate from the intrinsic function in its workings
> or has some other shortcomings unbeknownst to me, why not just make this a
> library function in site.sl and call it del_region to replace the very slow
> intrinsic?
>
> I know it is an abnormal use case, but still ...
>
> Regards,
> Morten
> _______________________________________________
> For list information, visit <http://jedsoft.org/jed/mailinglists.html>.
>
_______________________________________________
For list information, visit <http://jedsoft.org/jed/mailinglists.html>.
[2025 date index]
[2025 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]