Subject: bug#64985: 29.1; [PATCH] Byte-compilation of packages via package-vc doesn't correctly handle .elpaignore wildcards

From: Mattias Engdegård <[email-masked]>
Date: Tue, 1 Aug 2023 19:29:11 +0200

>> There might be another way to do this, e.g. so that we could optimize 
>> the regexp, but I'm not sure if Emacs has anything to optimize a list of 
>> *regexp* alternatives (rather than a list of *string* alternatives). I 
>> tested out 'rx' too, but no luck there either. This seemed like the best 
>> I could do without more extensive changes, which I wanted to avoid for 
>> the 29 branch.
>> 
> Note: 'rx' (well, 'rx-to-string') would work here too, but it didn't 
> optimize the list of regexp alternatives, and I found the code to be 
> harder to read (though I could just be doing it in a clumsy way).

rx doesn't attempt to left-factorise disjunctive patterns unless they are all literal strings or characters. I have considered a generalisation, but it would be done on the rx level and so wouldn't solve your immediate problem here.

An alternative would be to match against

(mapconcat #'identity byte-compile-ignore-files "\\|") ...)