SFML 5 defects: VideoMode dedup x3 (139x), allWindows erase (1001x), GL ext (149x) AngelScript 3 defects: FindNewOwner (100x), CompileSwitch (250x) Three.js 5 defects: WebGL binding (22x), StackNode filter (1875x), NodeBuilder (517x) pygame 4 defects: remove_internal (3001x), spritecollide dokill (3001x), switch_layer (3001x) Whitepaper: 98→115 sites, 44→48 ecosystems All unit tests pass: 6/6 each
12 lines
663 B
Diff
12 lines
663 B
Diff
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
|