Use HashMap::entry to avoid an extra lookup