Skip to content

[nfc] Fixed typos in comments in Sort.swift #37892

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

Merged
merged 3 commits into from
Jun 16, 2021
Merged

Conversation

NevinBR
Copy link
Contributor

@NevinBR NevinBR commented Jun 12, 2021

No description provided.

There is still an incongruity between where `srcHigh` and `destHigh` are displayed in the diagram:

`srcHigh` is shown at the location it logically represents, not its true position which is one past that, whereas `destHigh` (as well as `bufferHigh`) is shown at its true position (past the end) not at the location it logically represents.

I am not sure if that is intentional.
@@ -555,7 +555,7 @@ extension UnsafeMutableBufferPointer {
// (a) - for all i in 2..<runs.count:
// - runs[i - 2].count > runs[i - 1].count + runs[i].count
// (b) - for c = runs.count - 1:
// - runs[i - 1].count > runs[i].count
// - runs[c - 1].count > runs[c].count
Copy link
Member

Choose a reason for hiding this comment

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

👍🏻

// srcHigh destLow destHigh (past the end)
// Storage: [4, 4, 7, 8, 9, 16, x, x, x, x, x]
// ^ ^ ^
// srcHigh destLow destHigh (past the end)
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the original is odd for a couple reasons:

  1. That 6 isn't in the right spot; we wouldn't be merging a range of elements that isn't ordered correctly. (You fixed that by changing it to 16)
  2. srcHigh and destLow point to the same position, not consecutive ones. Looking at the loop below, they're actually always the same (because we move elements from the top of the initialized "Storage" region, which shifts the uninitialized region downward). We could eliminate one if that would make things clearer, but they shouldn't depict two different pointers in this diagram.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I wasn’t sure if there was a reason for doing it that way.

We could probably do something with, like, slashes as angled lines to show they’re both pointing to the same place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I went with a slash, not as an angled line, but as an actual slash.

Copy link
Collaborator

@xwu xwu left a comment

Choose a reason for hiding this comment

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

Just some centering of labels...

@NevinBR
Copy link
Contributor Author

NevinBR commented Jun 15, 2021

Just some centering of labels...

Thanks!

@natecook1000
Copy link
Member

Beauteous! 💖

@natecook1000
Copy link
Member

@swift-ci Please smoke test and merge

@swift-ci swift-ci merged commit 6c2c03d into swiftlang:main Jun 16, 2021
@NevinBR NevinBR deleted the patch-2 branch June 16, 2021 11:18
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.

4 participants