[bugfix] updated pinned counts on status delete (#3188)

* include pinned status when incrementing / decrementing status counts

* remove the pinned increment on status creation

* code comments

* microoptimize decr
This commit is contained in:
kim
2024-08-11 09:23:36 +00:00
committed by GitHub
parent 4a3ece0c6c
commit 865b3aeaac
4 changed files with 36 additions and 28 deletions

View File

@@ -23,6 +23,15 @@ type Number interface {
~uintptr | ~float32 | ~float64
}
// Decr performs a safe decrement of
// n, clamping minimum value at zero.
func Decr[N Number](n N) N {
if n <= 0 {
return 0
}
return n - 1
}
// Div performs a safe division of
// n1 and n2, checking for zero n2. In the
// case of zero n2, zero is returned.