Commit 6dd944a
Keep the digit-separator feature off the default hot path
PR fastfloat#369's "performance-neutral" claim did not hold: the default
(no-separator) parse was ~70% larger in the hot frame (parse_number_string
inlined into from_chars: 833 -> 1414 x86/arm64 instructions), because
1. parse_number_string is force-inlined (always_inline), and the runtime
dispatch inlined BOTH the has_separator==true and ==false instantiations
into the default caller -- dragging the entire separator-aware scanner
into the hot frame; and
2. the runtime separator branch survived in from_chars() even though a
default-constructed parse_options provably has no separator, because the
thin from_chars_caller forwarder was not inlined, so the compile-time
'\0' was lost across the call boundary and the branch (plus two calls)
could not be folded away.
Fixes:
* FASTFLOAT_NOINLINE + a cold parse_number_string_with_separator trampoline
so the separator instantiation stays strictly out of line; the default
caller only ever materializes the has_separator==false code.
* Force-inline from_chars_caller::call (all three specializations) so the
separator branch constant-folds away on the common from_chars() path.
Net: the default hot frame returns to 844 instructions (vs 833 on main; the
+11 is the unrelated parse_number_string refactor and is unchanged by this
commit). The separator path is unaffected and all tests pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 1d35d26 commit 6dd944a
2 files changed
Lines changed: 26 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
220 | 226 | | |
221 | 227 | | |
222 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
292 | 300 | | |
293 | 301 | | |
294 | 302 | | |
295 | | - | |
296 | | - | |
| 303 | + | |
| 304 | + | |
297 | 305 | | |
298 | | - | |
| 306 | + | |
| 307 | + | |
299 | 308 | | |
300 | 309 | | |
301 | 310 | | |
302 | 311 | | |
303 | 312 | | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
309 | 318 | | |
310 | 319 | | |
311 | 320 | | |
| |||
0 commit comments