rust-lang/rust — pull request #17857 by dotdash (2014-10-07 20:42:47+00:00)
Title: Generate better code for "large" vec![] macro invocations

Even when optimized, something like vec![1i,2,3,4,5,6,7,8,9,10] will
allocate three times, because LLVM can only drop the call based on the
observed size of the previous allocation. Using a simple macro to count
the number of elements, we can initialize the vector with the correct
size and avoid reallocations.

Since LLVM already does constant folding for us, the new count!() macro
results in a single integer constant even if building without
optimizations, so we don't end up with an awful lot of additions in the
generated code.