Merge pull request #8806 from nbp/issue-8152
Issue 8152 - Reduce number of attribute sets created by replaceChars.
This commit is contained in:
		
						commit
						ff8b35a643
					
				@ -107,11 +107,13 @@ rec {
 | 
			
		||||
  # replaceChars ["<" ">"] ["<" ">"] "<foo>" returns "<foo>".
 | 
			
		||||
  replaceChars = del: new: s:
 | 
			
		||||
    let
 | 
			
		||||
      substList = lib.zipLists del new;
 | 
			
		||||
      subst = c:
 | 
			
		||||
        (lib.fold
 | 
			
		||||
          (sub: res: if sub.fst == c then sub else res)
 | 
			
		||||
          {fst = c; snd = c;} (lib.zipLists del new)
 | 
			
		||||
        ).snd;
 | 
			
		||||
        let found = lib.findFirst (sub: sub.fst == c) null substList; in
 | 
			
		||||
        if found == null then
 | 
			
		||||
          c
 | 
			
		||||
        else
 | 
			
		||||
          found.snd;
 | 
			
		||||
    in
 | 
			
		||||
      stringAsChars subst s;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user