This is an archive of the discontinued Mercurial Phabricator instance.

radixbuf: make key reader function more flexible
AbandonedPublic

Authored by quark on Nov 27 2017, 1:30 PM.
Tags
None
Subscribers

Details

Reviewers
jsgf
Group Reviewers
Restricted Project
Summary

Previously the key reader function (convert KeyId to Key) can take a
&'a T and return a &'a [u8]. That was inspired by C void *, looked
flexible - in theory T could have some RefCell and do whatever it wants.
However, in practise, passing the radix buffer itself to the key reader
function is often desired and there is no easy way to do that cleanly.

This patch replaces the key reader arguments to an enum that support
different dedicated types of key readers - zero-copy from key buffer,
construct something from the radix buffer, or from both buffers.

This adds flexibility like embedding other data directly into the radix
buffer with an optional external key buffer as a dependence.

Test Plan

cargo test --lib

Diff Detail

Repository
rFBHGX Facebook Mercurial Extensions
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

quark created this revision.Nov 27 2017, 1:30 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptNov 27 2017, 1:30 PM
jsgf requested changes to this revision.Dec 7 2017, 12:19 PM
jsgf added a subscriber: jsgf.
jsgf added inline comments.
rust/radixbuf/src/key.rs
70

_like_

96

_like_

rust/radixbuf/src/radix.rs
138–141

I don't really understand this. It looks like something that could be expressed with a function and closures. Unless you really want the early return from $block?

180

This is too big to inline. The compiler can always inline it with LTO if it really wants to.

(Ditto other large functions with #[inline].)

233

Does rustfmt make a mess of this?

234

WAY to big to #[inline].

This revision now requires changes to proceed.Dec 7 2017, 12:19 PM
quark added inline comments.Dec 7 2017, 3:18 PM
rust/radixbuf/src/radix.rs
138–141

I'd be happy to rewrite if there is a cleaner way to get rid of this. What I want is not holding &radix_buf reference when running $block since $block may want &mut radix_buf.

180

Good idea.

233

It folds line 235 to 237 into a single line exceeding 100 chars.

quark abandoned this revision.Dec 14 2017, 8:51 PM

I have changed the childmap to use separate key buffer so this becomes no longer necessary.