Skip to content

Reuse shared JSONDecoder instances instead of allocating per call#79

Open
zmanian wants to merge 1 commit intomcintyre94:mainfrom
zmanian:fix/performance-shared-decoders
Open

Reuse shared JSONDecoder instances instead of allocating per call#79
zmanian wants to merge 1 commit intomcintyre94:mainfrom
zmanian:fix/performance-shared-decoders

Conversation

@zmanian
Copy link
Contributor

@zmanian zmanian commented Mar 14, 2026

Summary

  • SpritesAPIClient: The three streaming methods (streamService, streamServiceLogs, streamingRequest) were each creating a new JSONDecoder() per call. Now they use the existing self.decoder instance property.
  • GitHubAPIClient: Four decode sites were each creating a new JSONDecoder(). Added a shared static let jsonDecoder and use it throughout.

JSONDecoder allocation is lightweight, but when streaming hundreds of NDJSON events per chat session, reusing a single decoder avoids unnecessary allocations.

Test plan

  • Verify chat streaming works (sends message, receives streamed response)
  • Verify service log reconnection works
  • Verify checkpoint create/restore works
  • Verify GitHub repo list loads in repo picker

Generated with Claude Code

SpritesAPIClient stream methods now use the existing instance
decoder. GitHubAPIClient shares a single static decoder across
all decode sites.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant