-
Notifications
You must be signed in to change notification settings - Fork 1
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
Consider guaranteeing vendor list sort order #162
Comments
Hello @clbarnes, There are currently no plans to implement encoding for this crate. I agree with you that bitfield lists should be sorted, but I (personally) would prefer a solution which is optional either via an option or crate feature. |
The sorting was a bit of an aside - switching out the vec of vendor IDs for a btreeset would coincidentally guarantee order while primarily making containment checks more efficient (order being a useful tiebreaker vs a hashset). Containment checks are the entire purpose of vendor list so it seems like a use case worth prioritising. And serde serialises them exactly the same way so no changes needed there! I only mentioned sorting as well because in a read-only workflow as currently supported, a sorted vec is probably about as good as a btreeset because you can binary search it. |
The overhead for using the I will have to do some testing whether this overhead is worth placing behind an option / feature or if it should be the new default behavior. |
The overhead for using baseline (without BTreeSet)
with BTreeSet
So this would need to be placed behind an opt-in feature. |
The vendor consent vecs will almost always be used for membership checks. If encoding is ever added to this crate, guaranteeing ascending order and non-repeats through modification makes that much easier. You'd hope that people would encode their TC strings as sorted (always true for a bitfield, but possibly not true for ranges), but they might not, so it would be good to guarantee it.
Using a BTreeSet instead of a Vec guarantees ascending order and uniqueness, even if people modify it for re-encoding later. Otherwise, a sorted vec is an improvement as it allows binary searches. An
&mut self
method to sort all the internal vendor lists would be minimally invasive.The text was updated successfully, but these errors were encountered: