Page MenuHomePhabricator

rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
ClosedPublic

Authored by Alphare on Jul 10 2019, 7:46 AM.

Details

Summary

Both parse_dirstate and pack_dirstate can operate directly on the data
they're passed, which prevents the creation of intermediate data structures,
simplifies the function signatures and reduces boilerplate. They are exposed
directly to the Python for now, but a later patch will make use of them inside
hg-core.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Alphare created this revision.Jul 10 2019, 7:46 AM
Alphare updated this revision to Diff 15897.Jul 12 2019, 5:22 AM
kevincox accepted this revision.Jul 15 2019, 12:24 PM
kevincox added inline comments.
rust/hg-core/src/dirstate/mod.rs
16 ↗(On Diff #15897)

If these are always 20 bytes long you are best to use [u8; 20]. That way there will be no indirection. And since Vec is 3 words it will have a bigger immediate size on 64bit platforms.

rust/hg-core/src/dirstate/parsers.rs
85–86

The "proper" solution is SystemTime however I will admit that it is a bit more awkward to use. However if you are going to use Duration please document that it is the Duration since the Unix Epoch.

91

Would it be best to panic on overflow? now.as_secs().try_into::<i32>().expect("time overflow").

Alphare marked 3 inline comments as done.Jul 17 2019, 6:30 AM
Alphare updated this revision to Diff 16046.Wed, Jul 24, 11:22 AM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.