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

Optimize sorted matcher #359

Merged
merged 2 commits into from Jun 9, 2018
Merged

Optimize sorted matcher #359

merged 2 commits into from Jun 9, 2018

Conversation

ajalt
Copy link
Contributor

@ajalt ajalt commented Jun 9, 2018

Instead of sorting the list and comparing every value, we can iterate
through the list once and stop when we find an element that's larger
than the following element. This also allows us to add the out-of-order
element and its index to the error message.

A similar optimization was added to the containsInOrder matcher, with the additional benefit that it will now work on unsorted collections.

Instead of sorting the list and comparing every value, we can interate
through the list once and stop when we find an element that's larger
than the follow element. This also allow us to add the out-of-order
element and its index to the error message.
@ajalt
Copy link
Contributor Author

ajalt commented Jun 9, 2018

The build failure is the same as the master branch: the TestBoom test added in 0df6552

@sksamuel
Copy link
Member

sksamuel commented Jun 9, 2018

Yep, fixing the master build now as part of that issue.

@sksamuel
Copy link
Member

sksamuel commented Jun 9, 2018

This is a great pr, thanks.

@sksamuel sksamuel closed this Jun 9, 2018
@sksamuel sksamuel reopened this Jun 9, 2018
@sksamuel sksamuel merged commit 3ac09aa into kotest:master Jun 9, 2018
@ajalt ajalt deleted the sorted-speedup branch June 10, 2018 02:49
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

2 participants