[Chapel Merge] buildDefaultFunctions perf improvement

Branch: refs/heads/main
Revision: 56edd0d
Author: aconsroe-hpe
Link: Unavailable
Log Message:

Merge pull request #18624 from aconsroe-hpe/perf/buildDefaultFunctions-pretty

buildDefaultFunctions perf improvement

reviewed by @lydia-duncan

This work was an offshoot from looking at repeated calls to AList::get in the same scope, where this pass popped up because of the calls to getFormal(i).

The main changes here are:

Introduce a index so that functionExists only has to iterate over functions with a known name
Don't use collect_ast on rootModule just to iterate over all the TypeSymbol's
Use for_formals to remove the quadratic access time of repeated calls to getFormal(i)
These changes bring the buildDefaultFunctions pass from 3.6% of compile time for hello world to 1.4%

Tested with paratest

Modified Files:
M compiler/include/vec.h

M compiler/passes/buildDefaultFunctions.cpp

Compare: https://github.com/chapel-lang/chapel/compare/b93eb3eac4db...56edd0db1f85