Optimize appending text.

* lib/m4sugar/m4sugar.m4 (m4_append_uniq): Use index, not regular
expressions.

Signed-off-by: Eric Blake <ebb9@byu.net>
This commit is contained in:
Eric Blake 2007-10-02 20:23:03 -06:00
parent 57e51969f0
commit 53b2e90b42
2 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,9 @@
2007-10-02 Eric Blake <ebb9@byu.net>
Optimize appending text.
* lib/m4sugar/m4sugar.m4 (m4_append_uniq): Use index, not regular
expressions.
Optimize recursion.
* lib/m4sugar/m4sugar.m4 (m4_shiftn): This macro is called in a
lot of hot spots; optimize it for 2 and 3 shifts.

View File

@ -1553,11 +1553,11 @@ m4_define([m4_append],
# m4_append_uniq(MACRO-NAME, STRING, [SEPARATOR])
# -----------------------------------------------
# As `m4_append', but append only if not yet present.
# Like `m4_append', but append only if not yet present.
m4_define([m4_append_uniq],
[m4_ifdef([$1],
[m4_bmatch([$3]m4_defn([$1])[$3], m4_re_escape([$3$2$3]), [],
[m4_append($@)])],
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
[m4_append($@)])],
[m4_append($@)])])