You may like to read about the HEf_SVKEY flag in perlapi and in the perl source (hv.h and hv.c). It marks keys that are stored as SVs instead of raw strings (char *) inside the HV.
I have not investigated it deeply enough to known if it is usable for your purposes.
Comment on Re: Bidirectional lookup algorithm? (Updated: further info.)