Use entrySet instead of Keyset to improve performance (SPR-12356)

It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup.

Issue: SPR-12356