Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt some of the original swift-corelibs-foundation 5.10 implementation to regain performance in JSONEncoder #912

Draft
wants to merge 3 commits into
base: release/6.0
Choose a base branch
from

Conversation

kperryua
Copy link
Contributor

No description provided.

@@ -131,134 +69,165 @@ internal struct JSONWriter {
private let sortedKeys: Bool
private let withoutEscapingSlashes: Bool

var data = Data()
var bytes = [UInt8]()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reserve some space here. otherwise the first { is very expensive. I think we should always assume at least 256bytes of data? After that the reallocs will be very, very rare.

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