madrussian 347 Posted March 27, 2020 So... I have an array of obj types, and I want to remove all elements for which the obj type is a man. For my particular application (building path-finder), this bit of code needs to be fully optimized. In other words, every little nano-second counts! My code currently looks something like this: _objTypes = _objTypes select { ! ((typeOf _x) isKindOf "Man") }; Any way to make this run much faster? Specifically with any of the newer A3 scripting commands? (Btw - Seems most soldier types have a lengthy parent hierarchy, so that's what got me thinking so hard on this.) Thanks! Share this post Link to post Share on other sites
Dedmen 2653 Posted March 27, 2020 besides caching the isKindOf result, which I'm not sure if its faster. No. 1 Share this post Link to post Share on other sites
Tankbuster 1740 Posted March 27, 2020 Iskindof is pretty damn fast. You aren't going to optimise that line of code any more. 1 Share this post Link to post Share on other sites
gc8 977 Posted March 27, 2020 can't you use: _x isKindOf "Man" instead 1 Share this post Link to post Share on other sites
madrussian 347 Posted March 27, 2020 @gc8 Correct, good catch. Thanks guys, ok isKindOf it is then! Share this post Link to post Share on other sites
Tankbuster 1740 Posted March 27, 2020 He wants all objects that aren't man. Share this post Link to post Share on other sites
madrussian 347 Posted March 27, 2020 1 hour ago, Tankbuster said: He wants all objects that aren't man. I think @gc8 was pointing out that I could potentially optimize that code slightly by losing the typeOf command. As in, isKindOf will take a string or an obj (as 1st parameter). So if I had an array of objs (instead of types), the code might look something like: _objs = _objs select { ! (_x isKindOf "Man") }; Edit: And actually my original code (where I had obj types) wasn't quite right, should be: _objTypes = _objTypes select { ! (_x isKindOf "Man") }; Share this post Link to post Share on other sites