| Issue 236: | Optimise integer divide. | |
| 1 person starred this issue and may be notified of changes. | Back to list |
// f:Int, g:Int Std.int(f/g) gets compiled into ::Std_obj::_int((Float(f))/(Float(g))) It seems like it'd be a rather simple optimization to have this compiled as f/g instead
May 19, 2013
The problem is that untyped __cpp__("f/g") is not consistently going to work.
The variables in the compiled c++ code don't share the same names as the haxe variables all of the time, so this will not always be valid.
This is already done in the c# and java targets afaik (optimising to actual integer division).
|
This would involve looking for the "int" operator after the divide which is complicated. You can use this: var i:Int = untyped __cpp__("f/g"); To generate cpp: int i = f/g; If you are after extreme optimisations. I think a more complete solution might be a Math.idiv(f,g) for all platforms.