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

fix(common): Use zero-copy deserialization when FromStr is implemented #950

Merged
merged 1 commit into from
Mar 15, 2021

Conversation

jan-auer
Copy link
Member

We sometimes implement both FromStr and serde::Deserialize. In cases where
we share the implementation, we provide an explicit definition of FromStr and
use macros to implement serde::Deserialize.

There were two implementations of this macro:

  1. relay_common::impl_str_serialization
  2. relay_general::impl_str_serde

The implementation in relay_general allows to implement just deserialization
or serialization, but had a bug: It is not zero-copy. Instead, it always
allocates a String, only to then parse it.

In this PR, we deduplicate the macro and ensure that there are no allocations
when deserializing.

#skip-changelog

@jan-auer jan-auer requested a review from a team March 15, 2021 12:28
@jan-auer jan-auer self-assigned this Mar 15, 2021
@jan-auer jan-auer merged commit d9347f3 into master Mar 15, 2021
@jan-auer jan-auer deleted the fix/deserialize-str branch March 15, 2021 12:35
jan-auer added a commit that referenced this pull request Mar 15, 2021
* master:
  fix(common): Use zero-copy deserialization when FromStr is implemented (#950)
  fix(filter): Allow generic Slackbot to pass (#947)
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.

3 participants