Uh oh!
There was an error while loading. Please reload this page.
Add to SetOfVec at lexicographically correct position - #1060
Conversation
tarcieri
commented
May 12, 2023
Perhaps we need to better document/advertise this, but there's a That seems a lot more efficient than your proposed change. |
Yeah, damn, I overlooked that. But this doesn't really help, if you get a |
bkstein
commented
May 15, 2023
@tarcieri A test in the x509 crate tests the order of adding to |
tarcieri
commented
May 15, 2023
CI should be patched to use the in-repo I agree the existing method's ergonomics aren't great, but I'm a bit worried changing it like this creates an API which though convenient to use has some pathological corner cases performance-wise. If the primary use case is adding an item to an existing set, does that really make sense via in-place mutation, or would you normally pubfnappend(&self,new_elem:T) -> Result<Self>...which can be constructed by moving the inner |
Also Edit: this approach could also make for a general |
tarcieri
commented
May 15, 2023
Went ahead and impl'd |
tarcieri
commented
May 15, 2023
I have an alternative proposal in #1067. It also avoids making breaking changes. |
tarcieri
commented
May 15, 2023
bkstein
commented
May 16, 2023
tarcieri
commented
May 16, 2023
|
tarcieri
commented
May 16, 2023
Re: |
Motivation
When adding an element to a
SetOfVec, lexicographical ordering must be respected. This is required, when the content is DER encoded. Current solution is to forbid adding elements, that are not greater than all exisiting elements.This PR adds new elements in the correct position, which makes it possible to add elements to existing
SetOfVecs at any time in any order.Overhead?
The overhead introduced by this implementation is not really an overhead, because otherwise, the user of this crate would have to sort. And due to the current order check, there is no way around sorting anyway.
SetOfThe alloc-free
SetOfwas not changed. ButSetOf::add()could also be improved, I think.