perf: Eliminate redundant array allocations and dead code#15
Draft
perf: Eliminate redundant array allocations and dead code#15
Conversation
- Remove JSON.parse(JSON.stringify) fallback (Node 22+ always has structuredClone) - Combine map().filter() chains into single reduce operations - Add comments explaining optimizations in logging and session utils Co-authored-by: EvezArt <129563238+EvezArt@users.noreply.github.com>
- Replace filter().map() with single reduce() operations in TUI command completions - Optimize allowlist processing in web inbound access control - Reduces intermediate array allocations and improves performance Co-authored-by: EvezArt <129563238+EvezArt@users.noreply.github.com>
Co-authored-by: EvezArt <129563238+EvezArt@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Identify and suggest improvements for slow code
perf: Eliminate redundant array allocations and dead code
Feb 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Identified and eliminated inefficient array processing patterns and dead code that create unnecessary memory allocations in hot paths.
Changes
Array Processing (11 instances across 4 files)
Replaced
.filter().map()chains with single.reduce()operations to eliminate intermediate array allocations:Files:
src/tui/commands.ts(6),src/web/inbound/access-control.ts(2),src/plugins/discovery.ts(1),src/commands/status-all/gateway.ts(1)Dead Code Removal
Removed
JSON.parse(JSON.stringify())fallback insrc/config/schema.ts- Node 22+ (required in package.json) guaranteesstructuredClone()availability.Documentation
Added comments explaining non-obvious optimizations in
src/logging/logger.tsandsrc/gateway/session-utils.fs.ts.Impact
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.anthropic.com/opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw/openclaw/node_modules/.pnpm/vitest@4.0.18_@opentelemetry+api@1.9.0_@types+node@25.1.0_@vitest+browser-playwright@4._c5883c318af2013616434861e923ec39/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw/openclaw/node_modules/.pnpm/vitest@4.0.18_@opentelemetry+api@1.9.0_@types+node@25.1.0_@vitest+browser-playwright@4._c5883c318af2013616434861e923ec39/node_modules/vitest/dist/workers/forks.js /var/lib/dpkg/in--conditions /node_modules/@enode /opt/hostedtoolc--conditions --co�� -playwright@4._c--experimental-import-meta-resolve -playwright@4._c--require k/_temp/ghcca-no/home/REDACTED/work/openclaw/openclaw/node_modules/.pnpm/vitest@4.0.18_@opentelemeHKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice --experimental-ixdg-settings --require /home/REDACTED/wordefault-web-browser git(dns block)chatgpt.com/opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw/openclaw/node_modules/.pnpm/vitest@4.0.18_@opentelemetry+api@1.9.0_@types+node@25.1.0_@vitest+browser-playwright@4._c5883c318af2013616434861e923ec39/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw/openclaw/node_modules/.pnpm/vitest@4.0.18_@opentelemetry+api@1.9.0_@types+node@25.1.0_@vitest+browser-playwright@4._c5883c318af2013616434861e923ec39/node_modules/vitest/dist/workers/forks.js /var/lib/dpkg/in--conditions /node_modules/@enode /opt/hostedtoolc--conditions --co�� -playwright@4._c--experimental-import-meta-resolve -playwright@4._c--require k/_temp/ghcca-no/home/REDACTED/work/openclaw/openclaw/node_modules/.pnpm/vitest@4.0.18_@opentelemeHKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice --experimental-ixdg-settings --require /home/REDACTED/wordefault-web-browser git(dns block)example.com/opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw/openclaw/node_modules/.pnpm/vitest@4.0.18_@opentelemetry+api@1.9.0_@types+node@25.1.0_@vitest+browser-playwright@4._c5883c318af2013616434861e923ec39/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw/openclaw/node_modules/.pnpm/vitest@4.0.18_@opentelemetry+api@1.9.0_@types+node@25.1.0_@vitest+browser-playwright@4._c5883c318af2013616434861e923ec39/node_modules/vitest/dist/workers/forks.js 64.list lib4:amd64.list tools.list t.li�� amd64.list 64:amd64.list /node-gyp-bin/xdg-settings(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.