Make Prolog.copyHash an IdentityHashMap The map is used only for VariableTerms that have not yet been resolved to a value. In this case the only equality that makes sense is identity equality. The identity map is faster as it always avoids the virtual hashCode() and equals() methods on the keys.