On Wed, May 29, 2013 at 1:53 PM, Ziad Hatahet <hata...@gmail.com> wrote:
> Hi all,
>
> Does using Option incur a runtime cost (like increased memory usage)
> compared to a hypothetical case if Rust had a NULL type in the language? Or
> does it get optimized away, such that it is akin to using NULL in the first
> place (albeit safer of course)?
>
> I have not looked at any assemblies, ut my intuition says that a comparison
> with None is a single-word check, so it should be pretty fast.
>
> Thanks
>
> --
> Ziad

Any enum with a non-nullable pointer type (~T, @T, &T, ~[T], @[T],
~str, @str) and second zero-size variant is optimized to a nullable
pointer now. The optimization still needs to be extended to slices
though (they're two words, but the enum could also be 2 words, not 3).
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to