HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

U2I vs H2I

05-15-2008, 05:44 PM#1
Troll-Brain
Collapse JASS:
function U2I takes unit u returns integer
   return u
   return 0
endfunction

function H2I takes handle h returns integer
   return h
   return 0
endfunction

What is the fastest solution, if i use an unit variable.
For me, it should be the U2I function.

and yes i know the difference should be insignificant ...
05-15-2008, 05:50 PM#2
Toadcop
imo no difference... only h2i is more universal. =)
05-15-2008, 05:54 PM#3
d07.RiV
First of all, what is the question??
Second, I suppose the conversion from unit to handle does not have any overhead at all.
05-15-2008, 05:56 PM#4
Rising_Dusk
H2I is insignificantly faster, H2I is also significantly more universal.
05-15-2008, 06:22 PM#5
Toadcop
Quote:
U2I is insignificantly faster
O_o rly ? i think it makes no sense. cause unit is extended from handle. so handle is the main class. but well.

stupid question "stupid" answers =)
05-15-2008, 07:55 PM#6
Captain Griffen
It probably has to type cast from unit to handle, which shouldn't take any time really. It's probably less than the difference between typing '1.' and '1' for a real in the WE.
05-15-2008, 10:31 PM#7
Strilanc
I'm going to ahead and say there will be no difference whatsoever, except the inability to pass non-units to U2I. Both should compile to the same byte code.

Of course, it depends on Blizzard handled variable types. You can usually get away with totally ignoring the type at run-time (they do check it in native calls, but there is no native call here).
05-15-2008, 10:42 PM#8
Rising_Dusk
Quote:
Originally Posted by ToadCop
O_o rly ? i think it makes no sense. cause unit is extended from handle. so handle is the main class. but well.
Fuck me, I totally mistyped that. Yeah, H2I() would be insignificantly faster because handle is the parent data type.
05-15-2008, 11:22 PM#9
Toadcop
OMG !!! BRAIN EATING TT close this thread please !!!
// btw this is pure zadrotstwo =) discusing about 1 proccesor tact saving... =O i am scared...
05-15-2008, 11:35 PM#10
Vexorian
Quote:
Originally Posted by Toadcop
OMG !!! BRAIN EATING TT close this thread please !!!
// btw this is pure zadrotstwo =) discusing about 1 proccesor tact saving... =O i am scared...
Coming from the guy who preloads 6000 timers in order to speed up attaching ...
05-15-2008, 11:49 PM#11
Toadcop
yes but it's the uber thread >.<

it's kind a what is faster:

3+1
or
2+2 ?
see yes 2+2 maybe is faster but (i don't really know) but in fact it's 0 differense.

btw precached timers are also VERY save. // cause i align handle stack before creting them xD
05-15-2008, 11:55 PM#12
Vexorian
Quote:
Originally Posted by Rising_Dusk
Fuck me, I totally mistyped that. Yeah, H2I() would be insignificantly faster because handle is the parent data type.
Anyways, the reality is that functions using handle arguments in Jass all behave the same during runtime, the difference between handles only begins when calling the natives.
05-16-2008, 12:02 AM#13
Toadcop
when you will post the Heroes ? =)
05-16-2008, 12:06 AM#14
Vexorian
when Dusk comes back?

Friday sounds like the perfect day of the week to start the poll anyways.
05-16-2008, 12:08 AM#15
Toadcop
i have friday xD
+ RD is online...