--- a/src/htypes.hxx +++ b/src/htypes.hxx @@ -62,13 +62,18 @@ # define HUNSPELL_THREAD_LOCAL static #endif +// Field order chosen to minimize padding on 32-bit and 64-bit ABIs: +// pointers first, then 2-byte fields, then 1-byte fields. On wasm32 this +// packs to 20 bytes vs 24 with the upstream order; on 64-bit native, from +// 40 to 32 bytes. Both savings are meaningful for large dictionaries +// (e.g. Bulgarian has ~700K entries). struct hentry { + unsigned short* astr; // affix flag vector + struct hentry* next; // next word with same hash code + struct hentry* next_homonym; // next homonym word (with same hash code) unsigned short blen; // word length in bytes unsigned short clen; // word length in characters (different for UTF-8 enc.) short alen; // length of affix flag vector - unsigned short* astr; // affix flag vector - struct hentry* next; // next word with same hash code - struct hentry* next_homonym; // next homonym word (with same hash code) char var; // bit vector of H_OPT hentry options char word[1]; // variable-length word (8-bit or UTF-8 encoding) };