I think the deque was chosen because of a better push_front, but in combination with llvm::reverse the push_back'ed vector should be the better choice.
Details
Diff Detail
Unit Tests
Time | Test | |
---|---|---|
60 ms | x64 debian > LLVM.Bindings/Go::go.test |
Event Timeline
Deque, contrary to the vector, doesn't need to move the elements when growing. I'm not sure if that's relevant here though.
Have you checked what's on average the maximum size of Path on some larger repo?
Maybe using llvm::SmallVector with some well-thought (data-based) static number of elements would be better here, WDYT?
I have not checked what the sizes are. But I have thought about reserving the upper bound (all visited states) so there is only one allocation.
The moving of the content shouldn't be problematic, since we only have pointers.
Even if you choose a number, beyond that number it behaves like a vector (just without the data being on the stack), its really good for small vectors but its not bad for large ones. I'm not sure what the default N is if you don't specify a number? (0?)
Yeah I know what this is. On the link ownpan provided it says it chooses a good number for the stack.
My initial take on it was since I don't know how many states we mostly have, I don't try to guess and waste space on the stack if there is a chance we always go to the heap anyway.