Commit 9a18cf4
perf: avoid FSharpValue.GetUnionFields in toParam via cached tag reader
Replace the FSharpValue.GetUnionFields call in toParam (used when
unwrapping F# option values for query/form parameters) with a
precomputed union-tag reader.
GetUnionFields allocates a UnionCaseInfo object and an obj[] on every
call. The new approach:
- Caches FSharpValue.PreComputeUnionTagReader per option type (O(1) tag
check with no allocation after first call)
- Caches the Value PropertyInfo per option type (shared with
unwrapFSharpOption)
- Removes the now-redundant private optionValuePropCache, consolidating
both caches in one place
This matters for APIs that send many optional query/form parameters;
the improvement is visible when profiling clients that call high-
frequency endpoints with optional fields.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent deb9d9f commit 9a18cf4
1 file changed
Lines changed: 25 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
114 | 128 | | |
115 | 129 | | |
116 | 130 | | |
| |||
125 | 139 | | |
126 | 140 | | |
127 | 141 | | |
128 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
129 | 145 | | |
130 | 146 | | |
131 | 147 | | |
132 | 148 | | |
133 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
134 | 154 | | |
135 | | - | |
136 | | - | |
| 155 | + | |
137 | 156 | | |
138 | 157 | | |
139 | 158 | | |
| |||
287 | 306 | | |
288 | 307 | | |
289 | 308 | | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
| 309 | + | |
294 | 310 | | |
295 | 311 | | |
296 | 312 | | |
| |||
301 | 317 | | |
302 | 318 | | |
303 | 319 | | |
304 | | - | |
| 320 | + | |
305 | 321 | | |
306 | 322 | | |
307 | 323 | | |
| |||
0 commit comments