On Tue, Nov 12, 2013 at 2:17 PM, Tommi <[email protected]> wrote:
> Could the compiler figure out if a static item is not used and then elide it
> altogether. Or does it do this already?
>
If it's a `pub static`, and you're compiling a library, it cannot be
removed. But if it's just static and it's never used, it can and will
be optimized out. Example:
static X: [u8, ..30_000_000] = [1, ..30_000_000];
fn main() {
println("Look ma, small binary!");
}
When compiled with optimization, the resulting executable is 12K. Without, 29M.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev