help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Most used words in current buffer


From: Udyant Wig
Subject: Re: Most used words in current buffer
Date: Mon, 23 Jul 2018 00:13:34 +0530
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 07/22/2018 02:24 AM, Stefan Monnier wrote:
>>  (or (eq char 9) (eq char 10) (eq char 13)) (eq char 32))
>
> Aka (memq char '(?\t ?\n ?\r ?\s))

Indeed.  Not only does this form avoid the magic numbers, increase
readability, and abstract the representation, it fixes the error I made
in my code.

It turns out that my code worked by fluke: checking spaces.  I should
try not to post late at night.

>>       (cl-loop with word = nil
> [...]
>>             (forward-char)))
>
> This time you do the word-parsing char-by-char in Elisp.  I'd expect
> you'll get better performance with things like `forward-word` or
> (re-search-forward "\\<.*?\\>" nil t) so that the Elisp loop operates
> word-by-word rather than having to look at each and every character.

I read your message after Eric Abrahamsen's, which echoed your point.
Taking the advice paid off handsomely!  Thank you.

I posted `buffer-most-used-words-4' and an indication of its performance
in a follow up to Eric Abrahamsen's message.

>         Stefan

Udyant Wig
-- 
We make our discoveries through our mistakes: we watch one another's
success: and where there is freedom to experiment there is hope to
improve.
                                -- Arthur Quiller-Couch



reply via email to

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