﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
599	_FileListToArray costs O(N^2) instead of O(NlogN)	code65536	Gary	"Memory re-allocation is an expensive operation and as such, should be avoided.  For _FileListToArray to read a directory with N entries, it will need to perform N ReDim operations, and with each ReDim operation costing O(N) (assuming that ReDim is implemented efficiently), _FileListToArray will cost O(N^2^).

A very common way to mitigate this is to double the array size with each re-allocation instead of just incrementing it.  Under such a system, you will greatly reduce the number of ReDim operations, down to log2(N), bringing the final asymptotic cost of the function down to O(NlogN), which is optimal.

I am attaching a patch that will fix this problem.

With large directories with about 300 files, implementing this simple change reduced the time spent by over half (from ~10s for 100 runs down to ~4.8s for 100 runs in my benchmark).  Proportionally, the performance win will be even larger for directories with more entries."	Feature Request	closed	3.2.13.10	Standard UDFs		None	Completed		
