/* * similar to hv_fetch_ent, but takes string key and key len rather than SV * also skips magic and utf8 fu, since we are only dealing with internal tables */ HE *modperl_perl_hv_fetch_he(pTHX_ HV *hv, register char *key, register I32 klen, register U32 hash) { register XPVHV *xhv; register HE *entry; xhv = (XPVHV *)SvANY(hv); if (!HvARRAY(hv)) { return 0; } #ifdef HvREHASH if (HvREHASH(hv)) { PERL_HASH_INTERNAL(hash, key, klen); } else #endif if (!hash) { PERL_HASH(hash, key, klen); } entry = ((HE**)HvARRAY(hv))[hash & (I32)xhv->xhv_max]; for (; entry; entry = HeNEXT(entry)) { if (HeHASH(entry) != hash) { continue; } if (HeKLEN(entry) != klen) { continue; } if (HeKEY(entry) != key && memNE(HeKEY(entry), key, klen)) { continue; } return entry; } return 0; }
bool LUCY_Doc_Equals_IMP(lucy_Doc *self, cfish_Obj *other) { if ((lucy_Doc*)other == self) { return true; } if (!cfish_Obj_is_a(other, LUCY_DOC)) { return false; } lucy_DocIVARS *const ivars = lucy_Doc_IVARS(self); lucy_DocIVARS *const ovars = lucy_Doc_IVARS((lucy_Doc*)other); if (!ivars->doc_id == ovars->doc_id) { return false; } if (!!ivars->fields ^ !!ovars->fields) { return false; } // Verify fields. Don't allow any deep data structures. dTHX; HV *my_fields = (HV*)ivars->fields; HV *other_fields = (HV*)ovars->fields; if (HvKEYS(my_fields) != HvKEYS(other_fields)) { return false; } I32 num_fields = hv_iterinit(my_fields); while (num_fields--) { HE *my_entry = hv_iternext(my_fields); SV *my_val_sv = HeVAL(my_entry); STRLEN key_len; char *key; if (HeKLEN(my_entry) == HEf_SVKEY) { SV *key_sv = HeKEY_sv(my_entry); key = SvPV(key_sv, key_len); if (SvUTF8(key_sv)) { key_len = -key_len; } } else { key_len = HeKLEN(my_entry); key = key_len ? HeKEY(my_entry) : Nullch; if (HeKUTF8(my_entry)) { key_len = -key_len; } } SV **const other_val = hv_fetch(other_fields, key, key_len, 0); if (!other_val) { return false; } if (!sv_eq(my_val_sv, *other_val)) { return false; } } return true; }
SV* Application_font_encodings( Handle self, char * encoding) { AV * glo = newAV(); HE *he; PHash h = apc_font_encodings( self); if ( !h) return newRV_noinc(( SV *) glo); hv_iterinit(( HV*) h); for (;;) { void *value, *key; STRLEN keyLen; if (( he = hv_iternext( h)) == nil) break; value = HeVAL( he); key = HeKEY( he); keyLen = HeKLEN( he); av_push( glo, newSVpvn(( char*) key, keyLen)); } return newRV_noinc(( SV *) glo); }