Skip to content

Conversation

natecook1000
Copy link
Member

@natecook1000 natecook1000 commented May 12, 2021

This removes the #ifs to land on a single implementation for minAndMax() and adds a couple of additional tests.

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000 natecook1000 merged commit f9f3a5c into main May 13, 2021
@natecook1000 natecook1000 deleted the nate/minmax branch May 13, 2021 17:31
let c = iterator.next() ?? b
let d = iterator.next() ?? c
let (low, high) = try minAndMaxOf4(a, b, c, d)
var high = iterator.next() ?? low
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying low as high ended up being faster than branching when the latter would be nil?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC it didn't cost anything, and the following code is simpler.

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