Subject: bug#24012: 25.0.95; forward-comment backwards takes O(n^2)

From: Stefan Kangas <[email-masked]>
Date: Sun, 29 Sep 2019 07:15:22 +0200

Dmitry Gutov <[email-masked]> writes:

> On 7/17/16 2:04 PM, Leo Liu wrote:
>> 1. Use the attached file as an example, open it in emacs in ruby-mode
>> 2. Move point to end of buffer and eval (forward-comment (- (point)))
>> The last step takes about 0.25 seconds on my MacBook 3 GHz Intel Core
>> i7. If you double the lines of comments, the time increase by 4 folds.
>
> FWIW, it looks fixed in the master branch now.
>
> Probably by 14b95587520959c5b54356547a0a69932a9bb480, so no idea what exactly
> was causing it.

Indeed.  I only see O(n) on current master -- that is, if I use the
source code from the original report, and double the amount of lines
by C-x h M-w C-y, the time to evaluate this expression in a buffer
only doubles:

    (progn (end-of-buffer) (forward-comment (- (point))))

Leo, are you still seeing this issue?  If I don't hear back within a
couple of weeks, I'll just assume that this has been fixed and close
this bug.

Best regards,
Stefan Kangas