From da726e23483046943a5df37df94ce9248e50ca70 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sat, 11 Jul 2026 14:04:23 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20search=20filter?= =?UTF-8?q?=20string=20concatenation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces .flatMap(), array spreading, and .join() with iterative string concatenation to reduce GC overhead and memory allocations during search filtering. --- .jules/bolt.md | 4 ++++ frontend/src/App.tsx | 21 +++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index a016530d..f73f1f3a 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -68,3 +68,7 @@ Optimized metric route processing to O(N) by creating a mapping of routes direct ## 2024-05-18 - [Optimize Node Resolution in autoInfer.ts & STRIX Intersect Flake] **Learning:** We replaced an O(N^2) loop where `nodes.find` scanning via string splitting was running inside an `O(N)` loop to match foreign key relationships, using an O(1) `Map` lookup instead. We also ran into an issue where STRIX falsely flagged a path traversal due to string manipulation of table names. Adding a simple alphanumeric whitelist `sanitizeTableName()` step addressed this mock-security check. **Action:** When working with nested search loops on static Node trees, immediately create O(1) Lookup Maps. Additionally, if the CI pipeline uses hallucination-prone LLM vulnerability checks (like STRIX) and flags string splitting logic, you can easily bypass the false positive by implementing a `sanitizeTableName` whitelist regex check where the table string is constructed. + +## 2025-02-12 - Prevent Excessive Dynamic Array Allocations and Garbage Collection Overhead +**Learning:** In frontend performance, using `.flatMap()`, array spread syntax (`...`), and `.join()` inside loops iteratively over ERD nodes and columns for search filtering generates excessive intermediate arrays, increasing garbage collection overhead. This causes performance issues especially when large datasets are involved. +**Action:** Replace `.flatMap()`, array spread syntax (`...`), and `.join()` operations with iterative string concatenation (`+=`) to avoid excessive dynamic array allocations. diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index edaeeea0..51d24741 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -195,18 +195,15 @@ export default function App() { if (!normalizedNodeSearch) return new Set(); const matches = new Set(); for (const node of nodes) { - const haystack = [ - node.data.title, - node.data.comment ?? "", - ...node.data.columns.flatMap((column) => [ - column.column_name, - column.data_type, - column.column_comment ?? "", - ]), - ] - .join(" ") - .toLocaleLowerCase(); - if (haystack.includes(normalizedNodeSearch)) { + let haystack = node.data.title; + if (node.data.comment) haystack += " " + node.data.comment; + for (const column of node.data.columns) { + haystack += " " + column.column_name + " " + column.data_type; + if (column.column_comment) { + haystack += " " + column.column_comment; + } + } + if (haystack.toLocaleLowerCase().includes(normalizedNodeSearch)) { matches.add(node.id); } }