You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a vector of length n, it currently allocates 2 * n space, but for small vectors it only uses n... and should be able get away without allocations completely.
Note: the comparison function could unwind, so this will need to be careful about what it puts on the stack etc. to be failure safe... although there is a test that should help ensure that. [].swap is probably useful.
there may be some advantage to switching what implementation is used based on the size of the elements, e.g. for &mut [uint], [].swap is cheap, but for &mut [HundredKBStruct], many swaps may be more expensive than what one can do with an allocation. (Pure speculation on my part.) Of course, we could just avoid doing this, and people could go faster by boxing it and storing ~HundredKBStruct.
For a vector of length
n, it currently allocates2 * nspace, but for small vectors it only usesn... and should be able get away without allocations completely.Note: the comparison function could unwind, so this will need to be careful about what it puts on the stack etc. to be failure safe... although there is a test that should help ensure that.
[].swapis probably useful.Random notes:
&mut [uint],[].swapis cheap, but for&mut [HundredKBStruct], many swaps may be more expensive than what one can do with an allocation. (Pure speculation on my part.) Of course, we could just avoid doing this, and people could go faster by boxing it and storing~HundredKBStruct.