Summary
Interactive flows such as generateList()/interactiveSearch build strings and data structures each time a search is performed. For large numbers of commands or directories, string allocations and copying may dominate runtime and cause latency. The UI builds concatenated strings for display each time.
Reproduction / evidence
- src/search.cpp: generateList constructs a long string by iterating all paths and commands. Each invocation will allocate memory proportional to the total size.
Impact
- Increased latency for generating lists and for interactive sessions with large datasets.
- Higher memory churn leads to garbage in runtime and CPU overhead.
Suggested fixes / improvements
-
Use more efficient data structures for display generation:
- Avoid building a single giant std::string; use streaming to stdout or buffered writers that pre-allocate capacity when the size is known.
- Reuse buffers across calls when possible.
-
Implement pagination / lazy evaluation:
- Only generate and render portions of the list visible to the user (or requested), especially when integrated with fzf or pagers.
-
Profile hot paths and optimize critical loops:
- Use tools like perf or valgrind to find hotspots and inline small helpers, minimize copies, and use references where appropriate.
Files/places to review first
- src/search.cpp (generateList, interactiveSearch)
Severity: medium
Summary
Interactive flows such as generateList()/interactiveSearch build strings and data structures each time a search is performed. For large numbers of commands or directories, string allocations and copying may dominate runtime and cause latency. The UI builds concatenated strings for display each time.
Reproduction / evidence
Impact
Suggested fixes / improvements
Use more efficient data structures for display generation:
Implement pagination / lazy evaluation:
Profile hot paths and optimize critical loops:
Files/places to review first
Severity: medium