Cesium icon indicating copy to clipboard operation
Cesium copied to clipboard

More efficient constant conversion

Open ForNeVeR opened this issue 2 years ago • 2 comments

From #157:

Current implementation is inefficient for constants. For example, 1 + 'b' gives the following:

IL_0000: ldc.i4 1
IL_0005: ldc.i4 98
IL_000a: conv.u1
IL_000b: conv.i4
IL_000c: add
IL_000d: stloc V_0

As you see, the char is first converted from int to byte, and then back to int. This could be removed if we implement lowering to implicit casts - the cast expression would see that the operand is a constant and emit it immediately. But this would require a lot of refactoring. so I left it for another day.

ForNeVeR avatar Jul 30 '22 15:07 ForNeVeR

Isn't issue is done when I add TypeCastExpression? I belive this is expressible in the tree, so we can collapse constants.

kant2002 avatar Sep 13 '22 07:09 kant2002

We have a test (Cesium.CodeGen.Tests.CodeGenOperatorTests.AddIntToChar) that confirms we still do the aforementioned conversion to byte and to int.

So, nope, this doesn't seem to be complete.

ForNeVeR avatar Sep 13 '22 18:09 ForNeVeR