Minimize allocations during iteration

Always allocate the upper bound for key and value up front
and reuse it during the iteration.
Merge pull request #2 from spkrka/iteration_optimization

Iteration optimization