Speed up `replace-match' slightly
* src/search.c (Freplace_match): Speed up non-literal (but actually literal) common case. This makes (benchmark-run 1000000 (replace-regexp-in-string "a+" "foo" "ogihdipofdhookfdohkfdpokhpokhfdpokfdhpokfdhkdfkhgoadfphokfkhpofdkhkdpokf")) about 10% faster.
This commit is contained in:
parent
7ce721bdac
commit
f2bd2386a7
1 changed files with 7 additions and 0 deletions
|
@ -2387,6 +2387,13 @@ since only regular expressions have distinguished subexpressions. */)
|
|||
if (! NILP (string))
|
||||
CHECK_STRING (string);
|
||||
|
||||
/* Most replacement texts don't contain any backslash directives in
|
||||
the replacements. Check whether that's the case, which will
|
||||
enable us to take the fast path later. */
|
||||
if (NILP (literal)
|
||||
&& !memchr (SSDATA (newtext), '\\', SBYTES (newtext)))
|
||||
literal = Qt;
|
||||
|
||||
case_action = nochange; /* We tried an initialization */
|
||||
/* but some C compilers blew it */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue