[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual
From: |
Robert Pluim |
Subject: |
Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual |
Date: |
Wed, 06 Jun 2018 15:51:02 +0200 |
Noam Postavsky <address@hidden> writes:
> On 6 June 2018 at 03:43, Robert Pluim <address@hidden> wrote:
>
>>> And I think you'll want to give a limit
>>> to the looking-back calls, otherwise they can keep searching until the
>>> beginning of buffer.
>>
>> ((looking-back "(") should never look at more than one character.
>
> Perhaps it shouldn't, but Emacs doesn't make that kind of optimization:
>
> (with-temp-buffer
> (let ((last-command-event ?a))
> (dotimes (i 8)
> (self-insert-command (expt 10 i))
> (benchmark 1 '(looking-back "(")))))
> Elapsed time: 0.000036s
> Elapsed time: 0.000030s
> Elapsed time: 0.000066s
> Elapsed time: 0.000427s
> Elapsed time: 0.004068s
> Elapsed time: 0.040317s
> Elapsed time: 0.422173s
> Elapsed time: 1.514244s
>
> (with-temp-buffer
> (let ((last-command-event ?a))
> (dotimes (i 8)
> (self-insert-command (expt 10 i))
> (benchmark 1 '(looking-back "(" (1- (point)))))))
> Elapsed time: 0.000031s
> Elapsed time: 0.000027s [5 times]
> Elapsed time: 0.000041s
> Elapsed time: 0.000045s
>
>> I could always do (eq (char-before) ?() I suppose.
>
> That's probably better. But wait! This time you *should* have a backslash: ?\(
Thatʼs a matter of style, no? ?( works equally well, but emacs
convention appears to be ?\(
>> The regexp produced by (sentence-end) looks like itʼs fairly well
>> anchored. Besides, Iʼm not searching for an end-of-sentence, Iʼm
>> asking "Am I at end-of-sentence".
>
> Which is exactly why you should put a limit.
I donʼt understand that conclusion. If I have
some words. some other words
^
with point at '^', (looking-back (sentence-end)) will match. If point is
not at an end of sentence, looking-back won't go backwards through the
buffer attempting to find one.
Although I could limit it to (point-at-bol 0) just to be extra super
sure, but my benchmarking shows no appreciable difference.
Robert
- Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual, (continued)
- Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual, Eli Zaretskii, 2018/06/04
- Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual, Robert Pluim, 2018/06/04
- Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual, Eli Zaretskii, 2018/06/05
- Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual, Robert Pluim, 2018/06/05
- Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual, Noam Postavsky, 2018/06/05
- Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual, Robert Pluim, 2018/06/06
- Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual, Noam Postavsky, 2018/06/06
- Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual,
Robert Pluim <=
- Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual, Noam Postavsky, 2018/06/06
- Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual, Robert Pluim, 2018/06/06