Skip to content

Commit 53280cf

Browse files
authored
perf(rpc,openapi): speed up RPC and OpenAPI serializers (#1731)
## Summary Speeds up `RPCSerializer` and `OpenAPISerializer` round trips, mainly by skipping per-value handler condition checks for primitives and avoiding per-node path allocations while walking payloads. In same-process A/B benches against the previous implementation: - RPC round trips are roughly 1.5x to 2x faster - OpenAPI round trips are roughly 1.3x to 3x faster - Default construction (no custom handlers) allocates nothing ## Other changes - Blobs returned by terminal custom handlers are now collected into `maps`/`blobs`, so they survive FormData transport - Serializer and bracket-notation tests are rewritten around real-world round trips, edge cases, malicious payloads, and prototype pollution attacks, with 100% coverage of the touched files - Docs: bracket notation now lists keys containing `[` or `]` as a limitation ## Notes for reviewers - Custom handlers keep working unchanged. When a custom handler overrides or disables a built-in key, the serializer falls back to the previous scan behavior - On the fast path, custom handlers are not called for values built-ins already claim (primitives, null, and built-in object types); this is documented in code
1 parent 9a732a1 commit 53280cf

11 files changed

Lines changed: 972 additions & 217 deletions

apps/content/docs/openapi/bracket-notation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Bracket notation is designed to express structured data in constrained environme
5050
- Cannot represent empty structures like empty objects `{}` or empty arrays `[]`.
5151
- Cannot represent an array at the root level. For example, `0=red&1=blue` becomes `{ 0: 'red', 1: 'blue' }`, not `['red', 'blue']`.
5252
- Cannot represent objects whose keys are all numbers, because they can be mistaken for array indexes.
53+
- Cannot reliably represent keys that contain `[` or `]`.
5354

5455
::: info
5556
If bracket notation is used in query strings or form data, it also inherits the limitations of those formats. For example, values are always strings or files, and `null` or `undefined` cannot be represented.

0 commit comments

Comments
 (0)