Fixed-length strings allocate and deallocate faster

Fixed-length strings allocate and deallocate faster

Fixed-length strings are generally slower than conventional strings, because all VB string functions and operators only recognize conventional strings, thus all fixed-length strings must be transparently converted to and from conventional strings.

However, arrays of fixed-length strings occupy a contiguous area of memory, therefore they can be allocated and released much faster than arrays of conventional strings. For instance, an array of 100,000 fixed-length strings of 30 characters each is allocated in about half a second (on a Pentium 233MHz machine), whereas it takes more than 8 seconds to initialize the same amount of variable-length strings with 30 blanks. The latter array can be erased in about 0.35 seconds, but the array of fixed-length strings is deallocated instantaneously. If your application deals with such huge string arrays, consider the convenience of using fixed-length strings to optimize the allocation and release phase.


Share the Post: