MAXScript FAQ > How To Make It Faster > Recursive functions can be faster |
A recursive function is a function that calls itself in order to perform repetitive tasks.
The following scripted function returns a list of the animated subAnims of the object passed as parameter. The script works well and is not too slow.
The recursive code does the same job, but is much shorter and almost 25% faster! (In order to get some usable measurement, both scripts were executed 100,000 times - the first took 13.875 seconds, the recursive version only 10.656 seconds.
Pre-initialize arrays when final size is known
matchPattern is faster than findString