HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

UnitAddItem() vs UnitAddItemById()

04-06-2008, 04:31 PM#1
grupoapunte
Hey i been doing some optimization work on one of my maps and im completly cleaning BJ's functions. The question is what is better if i need to create an item and give it to the hero? UnitAddItem(HERO, CreateItem(....)) or UnitAddItemById(HERO, ITEMID) im sure that the hero has a free spot in the inventory so i guess best choice is UnitAddItemById() but maybe i can learn something from an experieced jasser

Thanks
04-06-2008, 06:50 PM#2
Burning Rose
Well I'm not that experienced with JASS, but as far as I can tell the less function calls the better. So I would go with the "byID" form, since it's one function.
04-07-2008, 04:08 AM#3
Hydrolisk
*Not experienced.*

I would say UnitAddItemById would be better, because the latter looks like two functions[?] stuffed into one. Also, UnitAddItemById looks like it directly references the ID (obviously) so it might not have to go through a string-ID conversion (theorizing that). Lastly, UnitAddItem has an extra pair of (parenthesis).
04-07-2008, 04:21 AM#4
Rising_Dusk
Spawning things by id is always faster, even if just minimally so. You won't see the difference in game, but sleep better knowing it's there.