Re: [rust-dev] num::cast

2013-10-29 Thread Brendan Zabarauskas
You can use the `--emit-llvm` flag with rustc to check out the IR. To increase the optimisation amount, you can use `--opt-level LEVEL`, or just `-O` for an optimisation level of 2. ~Brendan On 29/10/2013, at 6:00 AM, Rémi Fontan wrote: > Thanks. > > I hope that llvm its capable optimizing t

Re: [rust-dev] num::cast

2013-10-28 Thread Brendan Zabarauskas
Yes, it's a static cast, so llvm should optimise that out. Do note however that the API has changed in 0.9-pre, and num::cast now returns an Option. So your code would be: ~~~ let res: T = aVariable / num::cast(2).unwrap(); ~~~ LLVM should resolve the conditional at statically - I haven't check

[rust-dev] num::cast

2013-10-28 Thread Rémi Fontan
Hi, just checking performance wise, is num::cast() doing a dynamic type cast or a static cast. I'm writing some template code that works on Real and I need sometime to divide T:Real by 2 or compate with 0 or 1. I've been using num::zero() and num::one() so far but how about dividing by 2? shoul