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

DurationFormatter: Remove allocations #5383

Merged
merged 30 commits into from
Aug 21, 2024

Conversation

kartva
Copy link
Member

@kartva kartva commented Aug 16, 2024

follow up to #5321

@kartva
Copy link
Member Author

kartva commented Aug 17, 2024

@sffc @younies any clue why CI is not triggering?

@sffc
Copy link
Member

sffc commented Aug 17, 2024

@sffc @younies any clue why CI is not triggering?

It doesn't run if there are merge conflicts.

@kartva kartva requested a review from younies August 17, 2024 21:31
@kartva kartva marked this pull request as ready for review August 17, 2024 21:37
@kartva kartva requested review from Manishearth, sffc and a team as code owners August 17, 2024 21:37
@kartva kartva removed the request for review from a team August 17, 2024 21:37
@kartva kartva removed the request for review from Manishearth August 17, 2024 21:37
let mut list_sink = PartSink::new();
formatted_list.write_to_parts(&mut list_sink)?;

// 7. Let strings be a new empty List.
Copy link
Member

Choose a reason for hiding this comment

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

keep these comments and adjust them with the new implementation

Copy link
Member

Choose a reason for hiding this comment

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

unless they are redundant

Copy link
Member Author

Choose a reason for hiding this comment

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

They are redundant; I believe @sffc said that it was acceptable to have multiple part annotations from different formatters in the final output. (Let me know if I misunderstood or misquoted you)

The comments are responsible for stripping list formatter parts information from the output.

We could add a divergence from standard note here. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

It's probably good to move some of the spec line item comments to where they are done in the new code structure. But you don't need a 1-for-1 alignment. The code is spec-compliant so long as the behavior is the same; it doesn't need to be line-for-line the same.

Copy link
Member

@younies younies left a comment

Choose a reason for hiding this comment

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

Good job

@@ -235,6 +235,7 @@ diplomat-tool = { git = "https://github.com/rust-diplomat/diplomat", rev = "8744
# EXTRA_CAPI_DEPS
# EXTRA_BLOB_DEPS
# EXTRA_FS_DEPS
arrayvec = { version = "0.7.2", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

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

issue: we already have smallvec in this list, can you use that?

Copy link
Member

Choose a reason for hiding this comment

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

I think arrayvec is slightly better than smallvec in this instance because there is a known, small upper limit to the length of the vector. smallvec has code and branching to overflow to the heap, which we don't need here.

arrayvec is in Cargo.lock so it's not a new dependency.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

True. Flagging @Manishearth for the new runtime dependency.

Copy link
Member

Choose a reason for hiding this comment

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

If we're adding another crate on top of smallvec, I think it should be heapless, which has more features than arrayvec. I'm not convinced this is worth adding another crate though.

@kartva kartva requested a review from younies August 19, 2024 21:50
components/experimental/src/duration/format.rs Outdated Show resolved Hide resolved
let mut list_sink = PartSink::new();
formatted_list.write_to_parts(&mut list_sink)?;

// 7. Let strings be a new empty List.
Copy link
Member

Choose a reason for hiding this comment

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

It's probably good to move some of the spec line item comments to where they are done in the new code structure. But you don't need a 1-for-1 alignment. The code is spec-compliant so long as the behavior is the same; it doesn't need to be line-for-line the same.

@sffc sffc mentioned this pull request Aug 20, 2024
@younies younies merged commit 8adbf92 into unicode-org:main Aug 21, 2024
28 checks passed
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.

4 participants