Skip to content

Conversation

@SabrinaJewson
Copy link

@SabrinaJewson SabrinaJewson commented Jan 8, 2022

  • The itoa and ryu crates (the same crates serde_json uses) avoid allocating anything when serializing integers and floats.
  • By switching the code to work on bytes instead of &strs, expensive Unicode handling can be avoided (e.g. str::bytes is a lot cheaper to run than str::chars).
  • We can copy serde_json and start serialization with a capacity of 128, to avoid excessive reallocations.
  • Since we use bytes now we might as well expose ser::to_bytes.
  • Edit: I came back to this and overrode Serializer::collect_str because we can provide a more efficient implementation than the default.

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