Skip to content

feat: Add schema extension support, member JSON name extension - #1136

Merged
jbelkins merged 14 commits into
mainfrom
jbe/schema_extensions
Aug 5, 2026
Merged

feat: Add schema extension support, member JSON name extension#1136
jbelkins merged 14 commits into
mainfrom
jbe/schema_extensions

Conversation

@jbelkins

@jbelkins jbelkins commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Description of changes

Adds support for schema extensions, which are pieces of data that may be attached to schemas for future reference as a performance enhancement. Also adds a schema extension that allows for reuse of the UTF-8 bytes to be serialized in JSON for a member name.

  • Adds a mutable version of our existing UniquelyIndexedCollection to allow for storage of schema extensions with O(1) access time.
  • Adds lock-protected extension storage to the Schema type for the storage of schema extensions.
  • Adds a MemberNameExtension (for AWSJSON 1.0/1.1) and JSONNameExtension (for RestJSON1) that the JSON serializer uses to store UTF-8 bytes for a member's JSON name, so that they may be reused the next time the member is serialized.

Also:

  • Code for escaping special characters in JSON strings has been inlined and converted to array appends, because Foundation.Data stores small arrays (typically up to 14 bytes) as inline data, avoiding a heap allocation. This should increase performance for encoding of these characters.

Performance gains indicate 5-25% performance improvement on JSON serialization, depending on the characteristics of the payload being serialized.

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

jbelkins added 5 commits July 31, 2026 14:06
The clear, count, isEmpty, and allElements members of
UniquelyIndexedMutableCollection have no callers in production code and
are exercised by tests only, which the SwiftLint analyzer flags as
unused declarations.  Suppress the rule for that region rather than
delete them, so the type remains a complete, symmetric collection.
@jbelkins
jbelkins requested a review from sichanyoo August 4, 2026 20:32
@jbelkins
jbelkins merged commit 5f10bbb into main Aug 5, 2026
45 checks passed
@jbelkins
jbelkins deleted the jbe/schema_extensions branch August 5, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants