VB040
ReDim Preserve inside a loop
Visual Basic 6
Warning
VB6
ReDim Preserve copies the whole array every call; growing one element at a time inside a loop is quadratic
ReDim Preserve copies the whole array every call; growing one element at a time inside a loop is quadratic.
Why this severity
ReDim Preserve copies the whole array every call; growing one element at a time inside a loop is quadratic.
Known false positives
small bounded loops where the copy cost never matters.
Remediation example
ReDim items(1 To expectedCount) ' fill inside the loop, trim once after it