GNU bug report logs - #2816
regexp-opt: does not optimize 'Abc' and 'abc'

Previous Next

Package: emacs;

Reported by: Jari Aalto <jari.aalto <at> cante.net>

Date: Sun, 29 Mar 2009 15:35:04 UTC

Severity: wishlist

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Jari Aalto <jari.aalto <at> cante.net>
Subject: bug#2816: closed (Re: bug#2816: regexp-opt: does not optimize
 'Abc' and 'abc')
Date: Tue, 11 Mar 2025 16:45:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#2816: regexp-opt: does not optimize 'Abc' and 'abc'

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 2816 <at> debbugs.gnu.org.

-- 
2816: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=2816
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Kangas <stefankangas <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 2816-close <at> debbugs.gnu.org, Jari Aalto <jari.aalto <at> cante.net>
Subject: Re: bug#2816: regexp-opt: does not optimize 'Abc' and 'abc'
Date: Tue, 11 Mar 2025 09:44:31 -0700
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> A)
>
>>     (regexp-opt
>>       '("Abc"
>>         "abc"))
>
>>     => "\\(?:[Aa]bc\\)"
>
>> B)
>
>>     (regexp-opt
>>       '("Abc"
>>         "def"
>>         "abc"))
>
>>     => "\\(?:Abc\\|abc\\|def\\)"
>
>> Shouldn't regexp-opt optimize B case as well?
>
> The `opt' of regexp-opt should be understood in the sense of
> optimization used in compilers, not in the formal mathematical sense of
> "optimal".  I.e. it does some effort to improve things, but without any
> guarantee about what is and what isn't optimized.
>
> So, yes, it would be good if it did do what you suggest, but it's not
> a bug if it doesn't.

Without a proposed patch, I think it's unlikely that we'll make much
progress here.  After 16 years, I'm closing this bug now.

If anyone wants to propose improvements to `regexp-opt`, please open a
new bug report.

[Message part 3 (message/rfc822, inline)]
From: Jari Aalto <jari.aalto <at> cante.net>
To: Emacs bug BTS <submit <at> debbugs.gnu.org>
Subject: regexp-opt: does not optimize 'Abc' and 'abc'
Date: Sun, 29 Mar 2009 18:28:55 +0300
A)

    (regexp-opt
      '("Abc"
        "abc"))

    => "\\(?:[Aa]bc\\)"

B)

    (regexp-opt
      '("Abc"
        "def"
        "abc"))

    => "\\(?:Abc\\|abc\\|def\\)"

Shouldn't regexp-opt optimize B case as well?

Jari



This bug report was last modified 130 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.