Commit dcdcd61
perf: use HashSet<char> and String.exists for adorner detection in TextConversions
Two small improvements to TextConversions.RemoveAdorners:
1. Switch DefaultRemovableAdornerCharacters from F# Set<char> (O(log n) lookup)
to System.Collections.Generic.HashSet<char> (O(1) lookup). The set has ~26
characters; while individual operations are fast, this function is called on
every cell when parsing CSV/JSON/XML for AsInteger, AsDecimal, AsInteger64.
2. Replace the manual mutable-flag loop with String.exists, which short-circuits
on the first adorner match. The previous loop always iterated to the end even
after finding an adorner. For values like ',234' the adorner is at index 0,
so early exit skips 5 unnecessary iterations.
No API change — DefaultRemovableAdornerCharacters is private. The public
DefaultNonCurrencyAdorners and DefaultCurrencyAdorners members remain Set<char>.
All 2896 tests pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent ef12364 commit dcdcd61
1 file changed
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | | - | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
0 commit comments