This is an archive of the discontinued Mercurial Phabricator instance.

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
Lint Skipped
Unit
Unit Tests Skipped

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

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
81

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.

87

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.Jul 24 2019, 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.