java-topology/defects/nomad/patch/nomad-0005-reconnect-replacements-map.patch
russell@unturf.com 783e406633 pygame/libgdx: CWE-407 findings
pygame: CLEAN — runtime uses dict/set throughout (O(1) membership)
libgdx-0002: ModelBuilder.rebuildReferences Array.contains O(P*M) — patch
libgdx-0005: Stage.touchDragged touchFocuses.contains O(F^2) — patch
libgdx-0006: AfterAction.delegate currentActions.indexOf O(W*A) per frame — patch
unit: extend LibGDXTest to 7 tests, all PASS (50x-1971x speedup measured)
2026-03-30 09:13:34 -04:00

34 lines
1.1 KiB
Diff

# UNDF: (leave blank)
--- a/scheduler/reconciler/reconcile_cluster.go
+++ b/scheduler/reconciler/reconcile_cluster.go
@@ -1,6 +1,7 @@
import (
+ "golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)
@@ -1310,13 +1310,14 @@ func (a *allocReconciler) handleReconnectingAllocs(...) {
// A replacement allocation could fail and be replaced with another
// so follow the replacements in a linked list style
- replacements := []string{}
+ replacementsSet := make(map[string]struct{})
nextAlloc := reconnectingAlloc.NextAllocation
for {
val, ok := all[nextAlloc]
if !ok {
break
}
- replacements = append(replacements, val.ID)
+ replacementsSet[val.ID] = struct{}{}
nextAlloc = val.NextAllocation
}
// Find replacement allocations and decide which one to stop.
for _, replacementAlloc := range all {
if replacementAlloc == reconnectingAlloc {
continue
}
- if !slices.Contains(replacements, replacementAlloc.ID) || replacementAlloc.ServerTerminalStatus() {
+ if _, ok := replacementsSet[replacementAlloc.ID]; !ok || replacementAlloc.ServerTerminalStatus() {
continue
}