Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upMoving `ArrayVec`s has complexity O(capacity()) instead of O(len()) #94
Comments
This comment has been minimized.
This comment has been minimized.
|
I don't see a way of improving this, short of specialising |
This comment has been minimized.
This comment has been minimized.
|
@gnzlbg This seems to be a language-level (Rust) issue, and not arrayvec? As you know, we can't redefine how a value moves. |
This comment has been minimized.
This comment has been minimized.
|
(clone_from is already implemented: https://docs.rs/arrayvec/0.4.7/src/arrayvec/lib.rs.html#893-913 ) |
This comment has been minimized.
This comment has been minimized.
|
closed, in Rust we can't change how values of a type move. I would be interested in language-level discussion about what can be done about this. My suggestion for a workaround is to use a big arrayvec behind a pointer if you need to pass ownership of it around. |
gnzlbg commentedFeb 6, 2018
The title says it all: moving an
ArrayVechas complexityO(capacity())instead ofO(len()). This is pretty bad.It is trivial to construct examples that show a massive slowdown (100x's slower) with respect to C++'s
boost::container::static_vector.For example, moving an empty
ArrayVec<[u64; 512]>involvesmemcpying 4104 bytes instead of just 8 bytes (the size oflen). That's 513x more expensive than C++'sboost::container::static_vector.