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