Skip to main content

Module hashing

Module hashing 

Source
Expand description

Hash functions that must match their Java counterparts bit for bit.

Map records place child entries by a hash of the entry name, so reading a map requires reproducing the exact hash the Java implementation used when the map was written: java.lang.String::hashCode (computed over UTF-16 code units with wrapping 32-bit arithmetic) scrambled by the constants from MapRecord.

Functions§

compare_utf16_strings
Compares two strings the way java.lang.String::compareTo does: by UTF-16 code units. This differs from Rust’s str ordering for supplementary characters, which sort after the basic multilingual plane in Rust but between U+D7FF and U+E000 (as surrogates) in Java. Map leaf entries and template properties are ordered this way on disk.
map_entry_hash
Computes the hash under which a map record stores the entry named name, matching MapRecord.getHash: (name.hashCode() ^ M) * M + A.
utf16_string_hash
Computes java.lang.String::hashCode for text.