http://www.perlmonks.org?node_id=241422


in reply to Re: Re: Re: Re: Re: what's faster than .=
in thread what's faster than .=

This is definitely the kind of discussion I would like to be part of it.

People are talking with solid facts, insightful thoughts, strong supporting data ... And also talk with respect to each other, at the same time, with respect to facts found.

The other thing I would be interested in, is the performance difference between using linked list and (dynamically growing) array.

By using linked list, you would call malloc once for each element, but no realloc is called; by using array, you would call malloc once at the beginning, and then call realloc each time when it grows. I used the two approaches from time to time, but never seriously measured them.

Also you might mix the two approaches, by using a linked list of sub-arrays. the size of each array is fixed, and we grow the data structure by growing the linked list, attaching more sub-arrays to the linked list.