Skip to content

Commit 4e3d2ae

Browse files
Merge pull request #342 from alex-tselikovsky/issue/inefficient_string_replacement
changing string concatenation with StringBuilder.Append in Helper.ReplaceAll
2 parents 0f0698b + c54f509 commit 4e3d2ae

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

QueryBuilder/Helper.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Linq;
5+
using System.Text;
56
using System.Text.RegularExpressions;
67

78
namespace SqlKata
@@ -88,8 +89,9 @@ public static string ReplaceAll(string subject, string match, Func<int, string>
8889
);
8990

9091
return splitted.Skip(1)
91-
.Select((item, index) => callback(index) + item)
92-
.Aggregate(splitted.First(), (left, right) => left + right);
92+
.Select((item, index) => callback(index) + item)
93+
.Aggregate(new StringBuilder(splitted.First()), (prev, right) => prev.Append(right))
94+
.ToString();
9395
}
9496

9597
public static string JoinArray(string glue, IEnumerable array)

0 commit comments

Comments
 (0)