Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

faster case-insensitive search #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

saurabhagrawal-86
Copy link

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

@saurabhagrawal-86
Copy link
Author

@goodsign could you please review this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant