From b5f87b5407916c4049a3158cc944cebfd7a883a9 Mon Sep 17 00:00:00 2001 From: qiulaidongfeng <2645477756@qq.com> Date: Tue, 10 Oct 2023 12:43:40 +0000 Subject: runtime: use max/min func Change-Id: I3f0b7209621b39cee69566a5cc95e4343b4f1f20 GitHub-Last-Rev: af9dbbe69ad74e8c210254dafa260a886b690853 GitHub-Pull-Request: golang/go#63321 Reviewed-on: https://go-review.googlesource.com/c/go/+/531916 LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall Reviewed-by: Mauri de Souza Meneguzzo Reviewed-by: Dmitri Shuralyov Reviewed-by: Keith Randall --- src/runtime/mpagealloc.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/runtime/mpagealloc.go') diff --git a/src/runtime/mpagealloc.go b/src/runtime/mpagealloc.go index 3e789ab85c..f87565417f 100644 --- a/src/runtime/mpagealloc.go +++ b/src/runtime/mpagealloc.go @@ -1038,8 +1038,8 @@ func mergeSummaries(sums []pallocSum, logMaxPagesPerSum uint) pallocSum { // Merge the summaries in sums into one. // // We do this by keeping a running summary representing the merged - // summaries of sums[:i] in start, max, and end. - start, max, end := sums[0].unpack() + // summaries of sums[:i] in start, most, and end. + start, most, end := sums[0].unpack() for i := 1; i < len(sums); i++ { // Merge in sums[i]. si, mi, ei := sums[i].unpack() @@ -1055,12 +1055,7 @@ func mergeSummaries(sums []pallocSum, logMaxPagesPerSum uint) pallocSum { // across the boundary between the running sum and sums[i] // and at the max sums[i], taking the greatest of those two // and the max of the running sum. - if end+si > max { - max = end + si - } - if mi > max { - max = mi - } + most = max(most, end+si, mi) // Merge in end by checking if this new summary is totally // free. If it is, then we want to extend the running sum's @@ -1073,5 +1068,5 @@ func mergeSummaries(sums []pallocSum, logMaxPagesPerSum uint) pallocSum { end = ei } } - return packPallocSum(start, max, end) + return packPallocSum(start, most, end) } -- cgit v1.3