runtime: avoid an allocation in (*time.Timer).Reset

This commit is contained in:
Elias Naur
2025-05-09 15:52:48 +02:00
committed by Ron Evans
parent 2da9d26e21
commit 180662f038
6 changed files with 25 additions and 25 deletions
+5 -8
View File
@@ -39,20 +39,17 @@ func timerQueueAdd(tn *timerNode) {
*q = tn
}
func timerQueueRemove(t *timer) bool {
removedTimer := false
func timerQueueRemove(t *timer) *timerNode {
for q := &timerQueue; *q != nil; q = &(*q).next {
if (*q).timer == t {
scheduleLog("removed timer")
n := *q
*q = (*q).next
removedTimer = true
break
return n
}
}
if !removedTimer {
scheduleLog("did not remove timer")
}
return removedTimer
scheduleLog("did not remove timer")
return nil
}
// Goexit terminates the currently running goroutine. No other goroutines are affected.