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

Signed-off-by: riyueguang <rustruby@outlook.com>
This commit is contained in:
riyueguang
2025-03-24 17:35:40 +00:00
committed by GitHub
parent 85a33eb62b
commit 6fc8d0dc64
3 changed files with 5 additions and 36 deletions
+1 -4
View File
@@ -130,10 +130,7 @@ func (m *Manager) GetPruningHeight(height int64) int64 {
// the snapshot `m.pruneSnapshotHeights[0]` is already operated,
// so we can prune upto `m.pruneSnapshotHeights[0] + int64(m.snapshotInterval) - 1`
snHeight := m.pruneSnapshotHeights[0] + int64(m.snapshotInterval) - 1
if snHeight < pruneHeight {
return snHeight
}
return pruneHeight
return min(snHeight, pruneHeight)
}
// LoadSnapshotHeights loads the snapshot heights from the database as a crash recovery.