rowGroupHead[ referenceValuePosition ].elem should be cached outside the loop.