I implemented the solution of building an index of the files and then doing the for each, object in array type search through the list of filenames. It took my script from 10 seconds to less than a second because I need to do about 240 matches each time I run the script.
Something that is worth mentioning is that if you want your indexing loop to go faster or if you don't want to match the shortname of the file name (annoying!) then do the index loop like below. Also, don't use A_loopfilelongpath as it has to do extra conversions than A_LoopFileLongPath!
;build folder list takes takes 200-300 ms
loop, M:\* , 0 , 1
if instr(A_LoopFileName, "~");this part skips recording the short names
For searching in the list...