Commit a701296
committed
perf(printf): optimize shell metacharacter lookup with O(1) lookup table
Replace linear search through SHELL_META_CHARS string with a const lookup
table for O(1) character classification. This improves performance for
the printf %q implementation without changing behavior.
- Add SHELL_META_LOOKUP static array initialized at compile time
- Add is_shell_meta() helper using the lookup table
- Remove unused SHELL_META_CHARS constant1 parent ee02b5e commit a701296
1 file changed
+19
-4
lines changedLines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
20 | 29 | | |
21 | 30 | | |
22 | 31 | | |
23 | 32 | | |
24 | 33 | | |
25 | 34 | | |
26 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
27 | 42 | | |
28 | 43 | | |
29 | 44 | | |
| |||
33 | 48 | | |
34 | 49 | | |
35 | 50 | | |
36 | | - | |
| 51 | + | |
37 | 52 | | |
38 | 53 | | |
39 | 54 | | |
| |||
65 | 80 | | |
66 | 81 | | |
67 | 82 | | |
68 | | - | |
| 83 | + | |
69 | 84 | | |
70 | 85 | | |
71 | 86 | | |
| |||
0 commit comments