Subject: bug#36444: [PATCH] Improved regexp-opt KEEP-ORDER check

From: Mattias Engdegård <[email-masked]>
Date: Sun, 30 Jun 2019 14:28:57 +0200

Currently, regexp-opt does not attempt optimisation with KEEP-ORDER set if the input list contains a proper prefix of another element, like

 ("ab" "abcd")

on the grounds that the optimised string would be

 "ab\\(?:cd\\)?"

which would not preserve the match order. However, this also prevents

 ("abcd" "ab")

from being optimised, even though doing so would be harmless.

The attached patch strengthens the check, allowing more inputs to be optimised.