HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

GroupRemoveUnit and IsUnitInGroup

01-07-2009, 09:47 PM#1
Troll-Brain
if we need to remove GetTriggerUnit(), do we really need for speed freak to check if the unit is in the group before it, like that

Collapse JASS:
if IsUnitInGroup(GetTriggerUnit(),<group>) then
   call GroupRemoveUnit(<group>,GetTriggerUnit())
endif

or can we do simply that with the same speed, or maybe faster ?

Collapse JASS:
call GroupRemoveUnit(<group>,GetTriggerUnit())

EDIT : Ofc, if we don't need to know that the unit was on the group or not.
01-08-2009, 12:25 AM#2
Zerzax
You'll probably know whether or not the unit is in the group anyway. You should, at least. It's totally based on context, tell more of what your script is trying to do.
01-08-2009, 03:29 AM#3
DioD
You dont need any checks for this.

Just remove no errors will come.
01-08-2009, 03:31 PM#4
Troll-Brain
Quote:
Originally Posted by Zerzax
You'll probably know whether or not the unit is in the group anyway. You should, at least. It's totally based on context, tell more of what your script is trying to do.
No really i don't need it, believe me.

@ Diod : Yes i know that no error will come, but in fact my question is for speed freak only.

IsUnitIsGroup vs GroupRemoveUnit.
01-08-2009, 04:15 PM#5
DioD
For group check is near instant, but if+else+then slow.

Sadly there is no way to build if+else+then without if no jumps around same function lines allow.

Ah jump if equal + section markings for jass == divine power.
01-08-2009, 04:16 PM#6
Zerzax
GroupRemoveUnit would be faster, because IsUnitInGroup would require using conditionals in any application.
01-08-2009, 04:53 PM#7
Troll-Brain
Quote:
Originally Posted by Zerzax
GroupRemoveUnit would be faster, because IsUnitInGroup would require using conditionals in any application.
Are you sure about that, because in fact, most of the times the unit won't be in the group.
So if IsUnitInGroup is faster than GroupRemoveUnit, when the unit is not in the group, then i will use both, like i've said in the first post of this thread.

Could someone benchmark plz ? Because I can't use japi, thx.
01-08-2009, 05:18 PM#8
DioD
if else then is much more slower then any native.

benchmark will show it.
01-08-2009, 05:27 PM#9
Troll-Brain
Quote:
Originally Posted by DioD
if else then is much more slower then any native.

benchmark will show it.

ok but just to know, how many times ?
01-08-2009, 06:02 PM#10
Alexander244
Expand JASS:

war3err off, done three times, time for null-test subtracted, etc.

Times in microseconds:
Test 1: Test 2: Test 3: Test 4:
3.249 1.708 1.728 1.653
01-08-2009, 06:25 PM#11
Troll-Brain
Thx, is it the same if the unit is not in the group, i dunno how groups are handle, but i guess it should take more time, no ?
01-08-2009, 06:41 PM#12
Alexander244
Tests 2 & 4 don't have the unit in the group, tests 1 & 2 do. Otherwise tests 1 and 2 are the same, and tests 3 and 4 are the same.
01-08-2009, 06:57 PM#13
Troll-Brain
Quote:
Originally Posted by Alexander244
Tests 2 & 4 don't have the unit in the group, tests 1 & 2 do. Otherwise tests 1 and 2 are the same, and tests 3 and 4 are the same.

You want mean that ?

Quote:
Tests 2 & 4 don't have the unit in the group, tests 1 & 3 do. Otherwise tests 1 and 2 are the same, and tests 3 and 4 are the same
01-08-2009, 06:59 PM#14
Alexander244
opps, yes.
01-08-2009, 07:06 PM#15
Troll-Brain
Thx for testing.