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

difflib: optimize SplitLines #1

Merged
merged 1 commit into from
May 10, 2015
Merged

difflib: optimize SplitLines #1

merged 1 commit into from
May 10, 2015

Conversation

rdwilliamson
Copy link
Contributor

Use strings.SplitAfter to avoid an allocation and copy per line.

benchmark                    old ns/op     new ns/op     delta
BenchmarkSplitLines100       25744         7168          -72.16%
BenchmarkSplitLines10000     2227947       369944        -83.40%

benchmark                    old allocs     new allocs     delta
BenchmarkSplitLines100       109            1              -99.08%
BenchmarkSplitLines10000     10021          1              -99.99%

benchmark                    old bytes     new bytes     delta
BenchmarkSplitLines100       6144          1664          -72.92%
BenchmarkSplitLines10000     1030960       163840        -84.11%

pmezard pushed a commit that referenced this pull request May 10, 2015
difflib: optimize SplitLines
@pmezard pmezard merged commit f78a839 into pmezard:master May 10, 2015
@pmezard
Copy link
Owner

pmezard commented May 10, 2015

Nice, thanks.

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.

2 participants