tidb icon indicating copy to clipboard operation
tidb copied to clipboard

use golang built-in functions rather than mathutil

Open lance6716 opened this issue 1 year ago • 10 comments

Enhancement

like we can use max rather than

https://github.com/pingcap/tidb/blob/7158ac65ee454d38455cd636b562649b08906e18/pkg/util/mathutil/math.go#L71-L80

lance6716 avatar Oct 12 '24 02:10 lance6716

I have worked on this issue @lance6716

Anudhyan avatar Oct 12 '24 12:10 Anudhyan

/assign @Anudhyan

lance6716 avatar Oct 12 '24 13:10 lance6716

Thanks a lot @lance6716

Anudhyan avatar Oct 12 '24 13:10 Anudhyan

@lance6716 when will this be reviewed?

Anudhyan avatar Oct 12 '24 13:10 Anudhyan

@lance6716 when will this be reviewed?

I'll take a look at Monday

lance6716 avatar Oct 12 '24 13:10 lance6716

@lance6716 I have updated the code using inbuilt function and it is running without errors. Please check it

Anudhyan avatar Oct 14 '24 10:10 Anudhyan

@Anudhyan Please read the issue. Use golang built-in functions like https://pkg.go.dev/builtin#max. And delete mathutil. Max

lance6716 avatar Oct 14 '24 11:10 lance6716

@Anudhyan Please read the issue. Use golang built-in functions like https://pkg.go.dev/builtin#max. And delete mathutil. Max

@lance6716 Do I need to do the same for this file only? [tidb/pkg/util/mathutil/math.go]

I have used slices replace custom Max Min functions and removed mathutil.max from line 45 with ^uint64(0). Please guide me if there is any error from my side. I am contributing for the first time!

Anudhyan avatar Oct 14 '24 22:10 Anudhyan

Do I need to do the same for this file only? [tidb/pkg/util/mathutil/math.go]

No. Delete mathutil.Max and let caller use golang built-in max. Also for min and other proper functions.

lance6716 avatar Oct 15 '24 03:10 lance6716

@lance6716 I was working on this issue. This is the first time I am working on issue for TiDB. Please reassign it to me

Anudhyan avatar Oct 20 '24 05:10 Anudhyan

@lance6716 are you talking about this change:

result := math.Max(float64(a), float64(b))

VersatileVats avatar Oct 22 '24 04:10 VersatileVats

@lance6716 are you talking about this change:

result := math.Max(float64(a), float64(b))

I don't know where's the code you refer to. I think the issue is clear and I don't know how to provide more details

lance6716 avatar Oct 22 '24 04:10 lance6716

Okay, thanks for the clarification! So, @Anudhyan you have to delete mathutil.Max and mathutil.Min and replace them with Go's built-in max and min functions

VersatileVats avatar Oct 22 '24 04:10 VersatileVats

Okay, thanks for the clarification! So, @Anudhyan you have to delete mathutil.Max and mathutil.Min and replace them with Go's built-in math.Max and math.Min functions

The built-in functions are called max, min rather than math.Max and math.Min

lance6716 avatar Oct 22 '24 05:10 lance6716

Okay, thanks for the clarification! So, @Anudhyan you have to delete mathutil.Max and mathutil.Min and replace them with Go's built-in math.Max and math.Min functions

The built-in functions are called max, min rather than math.Max and math.Min

@lance6716 the built in max and min are not variadic in nature. So how will I implement it here for variable n set of arguments?

Anudhyan avatar Oct 24 '24 08:10 Anudhyan

Obviously max and min ARE variadic in nature. Please learn some basic golang knowledge before you contribute.

lance6716 avatar Oct 24 '24 11:10 lance6716

/assign @songzhibin97

lance6716 avatar Oct 24 '24 14:10 lance6716

@lance6716: GitHub didn't allow me to assign the following users: songzhibin97.

Note that only pingcap members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. For more information please see the contributor guide

In response to this:

/assign @songzhibin97

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.

ti-chi-bot[bot] avatar Oct 24 '24 14:10 ti-chi-bot[bot]