From fc6e1e7e5d3227f8f1d28f83c4c2d9fc772eceb8 Mon Sep 17 00:00:00 2001 From: pkucode Date: Sat, 29 Mar 2025 01:05:24 +0800 Subject: [PATCH] refactor: use the built-in max/min to simplify the code Signed-off-by: pkucode --- internal/bft/requestpool.go | 2 +- internal/bft/util.go | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/internal/bft/requestpool.go b/internal/bft/requestpool.go index 5b4242cc..d53e31d1 100644 --- a/internal/bft/requestpool.go +++ b/internal/bft/requestpool.go @@ -304,7 +304,7 @@ func (rp *Pool) NextRequests(maxCount int, maxSizeBytes uint64, check bool) (bat } } - count := minInt(rp.fifo.Len(), maxCount) + count := min(rp.fifo.Len(), maxCount) var totalSize uint64 batch = make([][]byte, 0, count) element := rp.fifo.Front() diff --git a/internal/bft/util.go b/internal/bft/util.go index 195b7f42..b8698386 100644 --- a/internal/bft/util.go +++ b/internal/bft/util.go @@ -60,13 +60,6 @@ func proposalSequence(m *protos.Message) uint64 { return math.MaxUint64 } -func minInt(a, b int) int { - if a < b { - return a - } - return b -} - // MarshalOrPanic marshals or panics when an error occurs func MarshalOrPanic(msg proto.Message) []byte { b, err := proto.Marshal(msg)