Issue 8152 - Reduce number of attribute set created by replaceChars.
This commit is contained in:
parent
74f4b0d27a
commit
be65ac7c32
|
@ -107,11 +107,13 @@ rec {
|
||||||
# replaceChars ["<" ">"] ["<" ">"] "<foo>" returns "<foo>".
|
# replaceChars ["<" ">"] ["<" ">"] "<foo>" returns "<foo>".
|
||||||
replaceChars = del: new: s:
|
replaceChars = del: new: s:
|
||||||
let
|
let
|
||||||
|
substList = lib.zipLists del new;
|
||||||
subst = c:
|
subst = c:
|
||||||
(lib.fold
|
let found = lib.findFirst (sub: sub.fst == c) null substList; in
|
||||||
(sub: res: if sub.fst == c then sub else res)
|
if found == null then
|
||||||
{fst = c; snd = c;} (lib.zipLists del new)
|
c
|
||||||
).snd;
|
else
|
||||||
|
found.snd;
|
||||||
in
|
in
|
||||||
stringAsChars subst s;
|
stringAsChars subst s;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue