perf: remove index panic code generation from ExtractIf next - #587
Conversation
|
note: The PR code matches the current rust alloc implementation |
|
You can check the panic paths further using |
|
yeah it's those tiny indexes and stuff like that that introduce unnecessary bound checks we already know code fulfills but LLVM can't you could have gotten your way as well by doing unchecked accesses wouldn't you?? |
Exactly, and that we are using unsafe anyway, so there is no need to use safe API and defeat the gain of unsafe.
Can you please give me an example? I'm not sure about what you mean. |
unsafe { v.get_unchecked_mut(i) }it's basically the same except that it doesn't do bound checks |
|
Yeah but I think that would be ugly, and I would have to watch for double drops, I'll prefer pointer API for these kind of stuff. |
|
more of the same |
While reviewing panic paths of smallvec I noticed we have a index check panic in
ExtractIfnextfunction.I checked it with the rust alloc itself and updated the algorithm to remove that mistake.
I believe this mistake was a port of the old rust alloc which got optimized later.