HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Condition() vs. Filter()?!

07-28-2007, 10:28 AM#1
Pyrogasm
I just noticed this today... there are two natives:
Collapse JASS:
native Filter takes code func returns filterfunc

// And this

native Condition takes code func returns conditionfunc
And I noticed (from seeing in another's code) that you can use Filter() the same way you would use a boolexpr filter, except he didn't set it to a variable or destroy it:
Collapse JASS:
call GroupEnumUnitsInRange (targets,targX,targY,radius,Filter(function Spirit_Trap_Filter))

So... which one should I be using, what's the difference, how does one properly use Filter(...), and does it matter?
07-28-2007, 10:59 AM#2
DioD
press ESC to have some fun
Attached Files
File type: w3mTEST.w3m (15.8 KB)
07-28-2007, 11:10 AM#3
Earth-Fury
Doesnt matter, and they supposedly return the same boolexpr for the same function input, so cleaning up is not important. (altho that caching may only be with Condition())
07-28-2007, 11:21 AM#4
Pyrogasm
I got:

Code:
CONDITION PASS, HANDLES SAME
FILTER PASS, HANDLES SAME
LOCATION NOT PASS, HANDLES NOT SAME
FILTER == CONDITION WTF LOL
Now WTF does that mean?
07-28-2007, 11:30 AM#5
DioD
this is "some fun", basicaly i was not able to add empty post...

original string

"FILTER PASS AS CONDITION, HANDLES SAME"

Filter and Condition return same boolexpr for a function, there is no difference.

1) Condition() == Condition()
2) Filter() == Filter()
3) Location() != Location()
4) Filter() == Condition()
07-28-2007, 11:32 AM#6
Earth-Fury
ok...

Condition() and Filter() both return subtypes of boolexpr. But all functions take boolexpr's, not the sub type, so theyre the same.

think of them as returning a global, constant variable based on the function you put in. its like GetTriggerUnit() returns the same unit when used multiple times in the same trigger. Thus, you don't need to destroy BoolExprs, because you may wanna use that one again, and the minor leak isnt worth the trouble.

Im not sure if its only Condition() that has this caching mechanism.
07-28-2007, 11:49 AM#7
Toadcop
they may got different unknown features =\ maybe Filter() is faster than Condition()... dunno
07-28-2007, 10:28 PM#8
Veev
Toadcop doesn't have a test map that proves Filter() is faster than Condition() by 0.00001 seconds?! What has the world come to?!
07-28-2007, 10:47 PM#9
Pyrogasm
Quote:
Originally Posted by Veev
Toadcop doesn't have a test map that proves Filter() is faster than Condition() by 0.00001 seconds?! What has the world come to?!
ROFLs.