[4.2] Hashing : factorize calculation of the cost

Please fix this alignment.