Commit 652033d
authored
Optimize _get_git_remote_for_setup
The optimization added `@cache` to `_get_theme()`, which instantiates a `CodeflashTheme` object by importing `init_config` and calling its constructor. Line profiler shows the original version spent ~12.3 ms per call (6.5 ms on import, 5.8 ms on instantiation). Since `_get_git_remote_for_setup` calls `_get_theme()` inside `inquirer.prompt` every time multiple remotes exist, repeated calls in a session (or across test cases) re-executed this work. Caching the theme object eliminated redundant imports and constructor calls, reducing the per-call overhead in `_get_git_remote_for_setup` from ~12.8 ms to ~7.5 ms (visible in the `inquirer.prompt` line dropping from 12.8 ms to 7.5 ms). The 18% runtime improvement comes from amortizing theme creation across all invocations, with the largest gains in tests simulating multiple-remote scenarios where the function is called repeatedly.1 parent 9022f9e commit 652033d
1 file changed
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
0 commit comments