-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
mathutil: replace mathutil functions with Go built-in functions #56620
base: master
Are you sure you want to change the base?
Conversation
Welcome @Anudhyan! |
Hi @Anudhyan. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @Anudhyan. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@Anudhyan: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@Anudhyan: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@b41sh please check this and merge this , if possible |
@hawkingrei please check this and merge this, if possible |
pkg/util/mathutil/math.go
Outdated
) | ||
|
||
// Abs implement the abs function according to http://cavaliercoder.com/blog/optimized-abs-for-int64-in-go.html |
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.
the old code is an optimized version. Please don't change it.
pkg/util/mathutil/math.go
Outdated
return minv | ||
} | ||
return n | ||
} | ||
|
||
// NextPowerOfTwo returns the smallest power of two greater than or equal to `i` | ||
// Caller should guarantee that i > 0 and the return value is not overflow. | ||
// NextPowerOfTwo returns the smallest power of two greater than or equal to `i`. | ||
func NextPowerOfTwo(i int64) int64 { |
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.
I'm not sure the performance of these two versions. If you want to change it, please post some benchmark tests
} | ||
|
||
// Max returns the largest one from its arguments. | ||
// Max returns the largest element from its arguments. | ||
func Max[T constraints.Ordered](x T, xs ...T) T { |
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.
The original issue wants to remove this function. Caller can use the built-in max
function instead
/retest |
@Anudhyan: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@Anudhyan: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What problem does this PR solve?
Issue Number: close #56594
Problem Summary:
mathutil
functions in favor of Go's built-in ones, like trading in a customMax
function for Go'smath.Max
🛠️.What changed and how does it work?
mathutil
), making things simpler and cleaner.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.