java-topology/defects/threejs/patch/threejs-0002-stacknode-set.patch

13 lines
691 B
Diff

# UNDF: UNDF-2026-000000310
Fixes threejs-0002: StackNode build() uses nodes.indexOf() inside filter callback —
O(n²) during shader graph compilation per unique node set comparison.
--- a/src/nodes/core/StackNode.js
+++ b/src/nodes/core/StackNode.js
@@ -380,7 +380,8 @@ class StackNode extends Node {
this._currentNode = null;
- const newNodes = this.nodes.filter( ( node ) => nodes.indexOf( node ) === - 1 );
+ // FIX threejs-0002: nodes.indexOf() inside filter = O(n²) — CWE-407
+ const nodesSet = new Set( nodes ); // O(n) build once
+ const newNodes = this.nodes.filter( ( node ) => ! nodesSet.has( node ) ); // O(1) per check