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

feat: implement efficient conversion from String #128

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

LeoniePhiline
Copy link
Contributor

Previous to this changeset, the implementation of
FromStr for Schedule allocated internally.

The same was true for TryFrom<&str> for Schedule,
which forwarded to the former.

Library users had no way to prevent the unnecessary
double allocation where a heap-allocated String
representation is already available,
whose ownership could be passed into the Schedule.

This changeset implements efficient conversion
from Cow<'_, str>, String and &str.

Borrowed expressions are only heap-allocated
if parsing succeeds.

Ownership of owned expressions is passed into
the Schedule, circumventing the previous double
allocation.

Implements #127

Previous to this changeset, the implementation of
`FromStr for Schedule` allocated internally.

The same was true for `TryFrom<&str> for Schedule`,
which forwarded to the former.

Library users had no way to prevent the unnecessary
double allocation where a heap-allocated `String`
representation is already available,
whose ownership could be passed into the `Schedule`.

This changeset implements efficient conversion
from `Cow<'_, str>`, `String` and `&str`.

Borrowed expressions are only heap-allocated
if parsing succeeds.

Ownership of owned expressions is passed into
the `Schedule`, circumventing the previous double
allocation.

Implements zslayton#127
Copy link
Owner

@zslayton zslayton left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

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