| 12-11-2007, 01:27 PM | #1 |
JASS:globals handle H integer I endglobals JASS:function Trig_test_Actions takes nothing returns nothing local integer I local handle H set I = 1 // any value set H = GetTriggerUnit() // the last set variable type is converted in the first variable type for the first variable (I) call BJDebugMsg(I2S(I)) endfunction //=========================================================================== function InitTrig_test takes nothing returns nothing set gg_trg_test = CreateTrigger( ) call TriggerRegisterPlayerSelectionEventBJ( gg_trg_test, Player(0), true ) call TriggerAddAction( gg_trg_test, function Trig_test_Actions ) endfunction I didn't test for all conversions but is it faster than call a H2I function ? PS : The globals values dont change |
| 12-11-2007, 01:35 PM | #2 |
It is faster than I2S(H2I()) in the sense that you are always converting 1 to string. Please, get a better example cause I don't understand what you want to say at all. |
| 12-11-2007, 03:02 PM | #3 |
the I2S was only for see i convert an handle to integer without using a function, so faster than use the bug return. and btw i tried to converted an integer as a string and just test it that, that's very strange. i've not the vocabulary for explain it JASS:globals integer I string S integer inc = -1 endglobals JASS:function Trig_test_Actions takes nothing returns nothing local integer I local string S set inc = inc +1 set S = null set I = inc call BJDebugMsg (S) endfunction //=========================================================================== function InitTrig_test takes nothing returns nothing set gg_trg_test = CreateTrigger( ) call TriggerRegisterTimerEventPeriodic( gg_trg_test, 0.2 ) call TriggerAddAction( gg_trg_test, function Trig_test_Actions ) endfunction |
| 12-11-2007, 03:05 PM | #4 | |
Quote:
Pure wisdom. Have a beer. ![]() first post: JASS:set I = 1 // any value call BJDebugMsg(I2S(I)) third post: JASS:set S = null call BJDebugMsg (S) You know I never saw anyone with a more appropriate nickname.... |
| 12-11-2007, 03:31 PM | #5 |
omg test before ! that won't display null >< |
| 12-11-2007, 03:45 PM | #6 |
What are the outputs you're getting? Tell us, or we'll ignore you. |
| 12-11-2007, 03:47 PM | #7 | |
Quote:
so what? Look why the hell you want to do this H2I "optimization" anyways. Even if it could be done, witch I doubt it is still pointless because performance gain would be at best.. well small. Maybe you should concentrate on making your map instead of making futile experiments. |
| 12-11-2007, 04:07 PM | #8 |
@cohadar : http://wc3campaigns.net/showthread.php?t=98199 an usefull experiment I just want to know if it's faster than use that : set integer = H2I(handle) and test the second example plz |
| 12-11-2007, 04:17 PM | #9 |
Let me guess, it displays random strings from memory? Anyone who has ever printed a bad string pointer in any programming language knows that. Just forget about it and go do something useful ok. |
| 12-11-2007, 04:44 PM | #10 | |
Quote:
no it's not random |
| 12-11-2007, 04:56 PM | #11 | |
Quote:
Yes it is. |
| 12-11-2007, 06:09 PM | #12 |
I suppose the question is, which is faster? JASS:globals handle H integer I endglobals function Foo takes nothing returns nothing local integer I local handle H set I = 1 set H = GetTriggerUnit() call BJDebugMsg(I2S(I)) endfunction JASS:function H2I takes handle h returns integer return h return 0 endfunction function Foo takes nothing returns nothing local integer I local handle H set H = GetTriggerUnit() set I = H2I(H) call BJDebugMsg(I2S(I)) endfunction |
| 12-11-2007, 06:39 PM | #13 |
ok thx Anitarf |
| 12-11-2007, 06:45 PM | #14 | |
Quote:
Actually the second will be slightly slower ( 1 user function call vs 0 function calls). The union like thing is a confusing bug in warcraft 3 that may break at anytime. The union bug has many known issues and can break local variables. The return bug has a long history is unlikely to break. |
| 12-11-2007, 06:53 PM | #15 |
I seem to recall that using the union bug more than once in a function causes huge leaks. |
