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)
This commit is contained in:
parent
ec395a01fc
commit
783e406633
11 changed files with 816 additions and 3 deletions
|
|
@ -0,0 +1,34 @@
|
|||
# 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue