[llvm-dev] ArrayRef vs SmallVectorImpl
Russell Wallace via llvm-dev
llvm-dev at lists.llvm.org
Fri May 3 09:38:57 PDT 2019
It is suggested in the documentation that if you would have declared a
function parameter as SmallVector<Foo,N>&, it is better to instead declare
it as SmallVectorImpl<Foo>&.
This makes sense, but it seems to me that it is better still to declare it
as ArrayRef<Foo>; a quick test suggests it compiles to the same (highly
efficient) code, and adds a bit more flexibility in case e.g. you someday
want to pass a std::vector.
By that logic, there is never any reason to take a SmallVectorImpl, because
ArrayRef is strictly better. Am I missing anything?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev