-
Notifications
You must be signed in to change notification settings - Fork 27
Modernize for Go 1.24.4 #43
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
| t := -INFINITY | ||
|
|
||
| for i := 0; i < count; i++ { | ||
| for i := range 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.
As much as I like C++'s notation, Go is just always easier to read, thank you.
RikusLategan
left a comment
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.
Master:
@RikusLategan ➜ /workspaces/cp (master) $ go test .
ok github.com/jakecoffman/cp/v2 0.009sModernize:
@RikusLategan ➜ /workspaces/cp (modernize) $ go test .
ok github.com/jakecoffman/cp/v2 0.003s
- Adding
--vto get more verbose tests does not reveal anything interesting. - Readability of the code has certainly improved.
|
Also the |
jakecoffman
left a comment
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.
LGTM
I'm assuming moving from interface{} to any isn't an API change since they mean the same thing, so I won't cut a new major version for this.
Yes, it is safe to assume this. |
Instead of removing the manual i++ increment, revert the for loop to its original pattern before PR jakecoffman#43. This maintains consistency with the pre-modernization code structure where loops with conditional continue statements use manual index management. The original pattern was: for i := 0; i < len(space.dynamicBodies); { if condition { continue // Skip i++ } i++ // Increment only when not skipping }
* Fix index out of range panic in ProcessComponents This fixes a regression introduced in commit f1e35a6 (modernize for loops 2). When modernizing the for loop from traditional style to range syntax, the manual i++ increment was not removed, causing a double-increment bug. The for..range statement automatically increments the index variable, so the manual i++ at line 606 caused the loop to skip indices and eventually panic with 'index out of range'. Fixes the panic that occurs when SleepTimeThreshold != INFINITY. * Revert to original loop pattern for consistency Instead of removing the manual i++ increment, revert the for loop to its original pattern before PR #43. This maintains consistency with the pre-modernization code structure where loops with conditional continue statements use manual index management. The original pattern was: for i := 0; i < len(space.dynamicBodies); { if condition { continue // Skip i++ } i++ // Increment only when not skipping }
Change Log
Refactoring (modernize)
slicespackage (optimization)interfacetoany