-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[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
Conversation
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
stdlib/public/core/Sort.swift
Outdated
// srcHigh destLow destHigh (past the end) | ||
// Storage: [4, 4, 7, 8, 9, 16, x, x, x, x, x] | ||
// ^ ^ ^ | ||
// srcHigh destLow destHigh (past the end) |
There was a problem hiding this comment.
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:
- 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 to16
) srcHigh
anddestLow
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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...
Co-authored-by: Xiaodi Wu <[email protected]>
Thanks! |
Beauteous! 💖 |
@swift-ci Please smoke test and merge |
No description provided.