refactor: use the built-in max/min to simplify the code (#12280)

Signed-off-by: russcoss <russcoss@outlook.com>
This commit is contained in:
russcoss
2025-09-16 20:14:21 -04:00
committed by GitHub
parent b225508c9b
commit 05d53457af
4 changed files with 4 additions and 20 deletions

View File

@@ -204,13 +204,8 @@ func (c *InputCache) ShiftDiscard(inputLen int, numKeep int) int {
targetFree = max(targetFree, 1)
currentFree := c.numCtx - inputLen
discard := targetFree - currentFree
if discard < 0 {
discard = 0
}
return discard
return max(targetFree-currentFree, 0)
}
type ErrReprocessInputs struct {

View File

@@ -242,13 +242,8 @@ func (c *InputCache) ShiftDiscard(inputLen int32, numKeep int32) int32 {
targetFree = max(targetFree, 1)
currentFree := c.numCtx - inputLen
discard := targetFree - currentFree
if discard < 0 {
discard = 0
}
return discard
return max(targetFree-currentFree, 0)
}
type ErrReprocessInputs struct {