monday
monday copied to clipboard
faster case-insensitive search
The findInString(where, what string) function implements a case-insensitive search by converting both strings to lowercase using strings.ToLower() and then using the inbuilt strings.Index() function. However, the strings.ToLower() function is expensive as it needs to allocate new memory to construct a string.
This diff attempts to optimize findInString() implementation by avoiding the construction of any new strings in the implementation.
The results of the BenchmarkFormat test show ~35-40% improvement.
Before:
BenchmarkFormat-12 610 1788567 ns/op
After:
BenchmarkFormat-12 880 1336956 ns/op
@goodsign could you please review this PR?