Lines Matching defs:hash

21 A HV structure represents a Perl hash.  It consists mainly of an array
23 array is indexed by the hash function of the key, so each linked list
24 represents all the hash entries with the same hash value. Each HE contains
26 holds the key and hash value.
104 HVhek_UTF8. The value of this flag bit matters for (regular) hash key
111 (regular) hash key lookups.
113 But for the shared string table (the private "hash" that manages shared hash
115 (HVhek_WASUTF8 set and clear), so the code performing lookups in this hash
120 the point where hash passes the "large" hash threshold, and no longer uses
124 ignored for hash lookups) but must always be clear in the keys in the shared
132 below to determine whether to set HvHASKFLAGS() true on the hash as a whole.
134 (up front) that a hash contains non-8-bit keys, if they want to use different
136 (avoiding needing to store an extra byte per hash key), and they need to know
137 that this holds *before* iterating the hash keys. Only Storable seems to use
181 S_save_hek_flags(const char *str, I32 len, U32 hash, int flags)
193 HEK_HASH(hek) = hash;
231 /* We already shared this hash key. */
281 /* We already shared this hash key. */
333 These each store SV C<val> with the specified key in hash C<hv>, returning NULL
335 within the hash (as in the case of tied hashes). Otherwise it can be
338 They differ only in how the hash key is specified.
351 C<hv_store> has another extra parameter, C<hash>, a precomputed hash of the key
362 if all your code does is create SVs then store them in a hash, C<hv_store>
375 Stores C<val> in a hash. The hash key is specified as C<key>. The C<hash>
376 parameter is the precomputed hash value; if it is zero then Perl will
377 compute it. The return value is the new hash entry so created. It will be
379 stored within the hash (as in the case of tied hashes). Otherwise the
386 if all your code does is create SVs then store them in a hash, C<hv_store>
403 These return a boolean indicating whether the specified hash key exists.
415 These return the SV which corresponds to the specified key in the hash.
425 that if there is no value in the hash associated with the given key, then one
436 the specified hash key exists. C<hash>
437 can be a valid precomputed hash value, or 0 to ask for it to be
448 Returns the hash entry which corresponds to the specified key in the hash.
449 C<hash> must be a valid precomputed hash number for the given C<key>, or 0
452 accessing it. The return value when C<hv> is a tied hash is a pointer to a
465 const int action, SV *val, const U32 hash)
479 return hv_common(hv, NULL, key, klen, flags, action, val, hash);
484 int flags, int action, SV *val, U32 hash)
522 any passed-in computed hash value. */
523 hash = 0;
558 action, hash);
620 0 /* compute hash */);
629 newSV_type(SVt_NULL), hash);
677 hash = 0;
722 hash = 0;
774 /* If the caller calculated a hash, it was on the sequence of
777 so the hash we need is different. */
778 hash = 0;
785 hash = SvSHARED_HASH(keysv);
787 else if (!hash)
788 PERL_HASH(hash, key, klen);
795 entry = (HvARRAY(hv))[hash & (I32) HvMAX(hv)];
829 if (HeHASH(entry) != hash) /* strings can't be equal */
841 /* We match if HVhek_UTF8 bit in our flags and hash key's
850 = share_hek_flags(key, klen, hash, flags & ~HVhek_FREEKEY);
855 /* PL_strtab is usually the only hash without HvSHAREKEYS,
923 sv, hash);
931 " a restricted hash");
955 val, hash);
974 oentry = &(HvARRAY(hv))[hash & (I32) xhv->xhv_max];
980 HeKEY_hek(entry) = share_hek_flags(key, klen, hash, flags);
983 /* PL_strtab is usually the only hash without HvSHAREKEYS, so putting
993 HeKEY_hek(entry) = save_hek_flags(key, klen, hash, flags);
1028 "[TESTING] Inserting into a hash during each() traversal results in undefined behavior"
1048 if (items /* hash has placeholders */
1049 && !SvREADONLY(hv) /* but is not a restricted hash */) {
1050 /* If this hash previously was a "restricted hash" and had
1057 readonly flag, because Storable always pre-splits the hash.
1059 avoid needing to split the hash at all. */
1097 Evaluates the hash in scalar context and returns the result.
1099 When the hash is tied dispatches through to the SCALAR method,
1101 in the hash.
1144 hv_pushkv(): push all the keys and/or values of a hash onto the stack.
1146 () = %hash;
1147 () = keys %hash;
1148 () = values %hash;
1150 Resets the hash's iterator.
1214 If the hash is tied dispatches through to the SCALAR tied method,
1215 otherwise if the hash contains no keys returns 0, otherwise returns
1221 In a large hash this could be a lot of buckets.
1254 These delete a key/value pair in the hash. The value's SV is removed from
1255 the hash, made mortal, and returned to the caller.
1270 Deletes a key/value pair in the hash. The value SV is removed from the hash,
1273 be returned if the key is not found. C<hash> can be a valid precomputed hash
1281 int k_flags, I32 d_flags, U32 hash)
1304 NULL, hash);
1328 hash = 0;
1359 hash = SvSHARED_HASH(keysv);
1361 else if (!hash)
1362 PERL_HASH(hash, key, klen);
1364 first_entry = oentry = &(HvARRAY(hv))[hash & (I32) HvMAX(hv)];
1398 if (HeHASH(entry) != hash) /* strings can't be equal */
1425 " a restricted hash");
1429 * If a restricted hash, rather than really deleting the entry, put
1581 " a restricted hash");
1594 shared hash keys benefit the first two greatly, because keys are likely
1599 well as the hash is a memory hit, if they are never actually shared with a
1600 second hash. Hence we turn off shared hash keys if a (regular) hash gets
1616 /* This hash appears to be growing quite large.
1711 Attempt to grow the hash C<hv> so it has at least C<newmax> buckets available.
1794 The content of C<ohv> is copied to a new hash. A pointer to the new hash is
1811 /* It's an ordinary hash, so copy it fast. AMS 20010804 */
1851 const U32 hash = HeHASH(oent);
1854 HeKEY_hek(ent) = save_hek_flags(key, len, hash, flags);
1900 a pointer to a hash (which may have C<%^H> magic, but should be generally
1901 non-magical), or C<NULL> (interpreted as an empty hash). The content
1902 of C<ohv> is copied to a new hash, which has the C<%^H>-specific magic
1903 added to it. A pointer to the new hash is returned.
2004 Frees all the elements of a hash, leaving it empty.
2005 The XS equivalent of C<%hash = ()>. See also L</hv_undef>.
2007 See L</av_clear> for a note about the hash possibly being invalid on
2028 /* restricted hash: convert all keys to placeholders */
2040 "Attempt to delete readonly key '%" SVf "' from a restricted hash",
2076 Clears any placeholders from a hash. If a restricted hash has any of its keys
2079 it so it will be ignored by future operations such as iterating over the hash,
2080 but will still allow the hash to have a value reassigned to the key at some
2081 future point. This function clears any such placeholder keys from the hash.
2162 * Returns null on empty hash. Nevertheless null is not a reliable
2163 * indicator that the hash is empty, as the deleted entry may have a
2232 Undefines the hash. The XS equivalent of C<undef(%hash)>.
2234 As well as freeing all the elements of the hash (like C<hv_clear()>), this
2235 also frees any auxiliary data and storage associated with the hash.
2237 See L</av_clear> for a note about the hash possibly being invalid on
2281 xhv_eiter is NULL, including handling the case of a tied hash partway
2286 /* HvHasAUX() is true for a hash if it has struct xpvhv_aux allocated. That
2289 a hash is "undefined" (this function), but some must persist until it is
2295 non-pointer values are correct for an empty hash. The structure state
2360 HvMAX(hv) = PERL_HASH_DEFAULT_HvMAX; /* 7 (it's a normal hash) */
2384 Returns the number of hash buckets that happen to be in use.
2390 purposes, and the number of used hash buckets is not
2393 hash.
2466 Prepares a starting point to traverse a hash table. Returns the number of
2467 keys in the hash, including placeholders (i.e. the same as C<HvTOTALKEYS(hv)>).
2471 hash buckets that happen to be in use. If you still need that esoteric
2578 Perl_croak(aTHX_ "This Perl has not been built with support for randomized hash key traversal but something called Perl_hv_rand_set().");
2638 U32 hash;
2701 PERL_HASH(hash, name, len);
2702 *spot = name ? share_hek(name, flags & SVf_UTF8 ? -(I32)len : (I32)len, hash) : NULL;
2743 U32 hash;
2750 PERL_HASH(hash, name, len);
2772 (aux->xhv_name_u.xhvnameu_names)[count] = share_hek(name, (flags & SVf_UTF8 ? -(I32)len : (I32)len), hash);
2786 (aux->xhv_name_u.xhvnameu_names)[1] = share_hek(name, (flags & SVf_UTF8 ? -(I32)len : (I32)len), hash);
2901 Returns entries from a hash iterator. See C<L</hv_iterinit>>.
2903 You may call C<hv_delete> or C<hv_delete_ent> on the hash entry that the
2905 iterator. Note that in this case the current entry is deleted from the hash
2913 Returns entries from a hash iterator. See C<L</hv_iterinit>> and
2951 always reached even if the hash had no keys.
2957 being true. defined %hash is already deprecated.
2964 In Perl_hv_iternext_flags(), clarify and generalise the empty hash bailout code.
2966 which skipped the entire while loop if the hash had no keys.
2967 (If the hash has any keys, HvARRAY() cannot be NULL.)
3006 /* one HE per MAGICAL hash */
3039 /* At start of hash, entry is NULL. */
3058 "Use of each() on hash after insertion without resetting hash iterator results in undefined behavior"
3066 /* Skip the entire loop if the hash is empty. */
3075 /* There is no next one. End of the hash. */
3114 Returns the key from the current position of the hash iterator. See
3141 Returns the key as an C<SV*> from the current position of the hash
3159 Returns the value from the current position of the hash iterator. See
3211 Adds magic to a hash. See C<L</sv_magic>>.
3217 C<len> and C<hash> must both be valid for C<str>.
3223 Perl_unsharepvn(pTHX_ const char *str, I32 len, U32 hash)
3225 unshare_hek_or_pvn (NULL, str, len, hash);
3237 hek if non-NULL takes priority over the other 3, else str, len and hash
3238 are used. If so, len and hash must both be valid for str.
3241 S_unshare_hek_or_pvn(pTHX_ const HEK *hek, const char *str, I32 len, U32 hash)
3266 hash = HEK_HASH(hek);
3280 if ((Svp = hv_fetch(PL_strtab, tmpsv, FALSE, hash))) {
3282 hv_delete(PL_strtab, str, len, G_DISCARD, hash);
3286 oentry = &(HvARRAY(PL_strtab))[hash & (I32) HvMAX(PL_strtab)];
3296 if (HeHASH(entry) != hash) /* strings can't be equal */
3328 * len and hash must both be valid for str.
3331 Perl_share_hek(pTHX_ const char *str, SSize_t len, U32 hash)
3353 PERL_HASH(hash, str, len);
3358 return share_hek_flags (str, len, hash, flags);
3362 S_share_hek_flags(pTHX_ const char *str, STRLEN len, U32 hash, int flags)
3366 const U32 hindex = hash & (I32) HvMAX(PL_strtab);
3372 Perl_croak_nocontext("Sorry, hash keys must be smaller than 2**31 bytes");
3378 hv_store(PL_strtab, str, len, NULL, hash);
3387 if (HeHASH(entry) != hash) /* strings can't be equal */
3424 HEK_HASH(hek) = hash;
3572 hash with only 8 entries in its array. */
3576 the hash we build from it. */
3589 U32 hash = chain->refcounted_he_hash;
3591 U32 hash = HEK_HASH(chain->refcounted_he_hek);
3593 HE **oentry = &((HvARRAY(hv))[hash & max]);
3598 if (HeHASH(entry) == hash) {
3600 than the key we've already put in the hash, so if they are
3654 flags, but it's probably not worth it, as this per-hash flag is only
3668 are interpreted as Latin-1. C<hash> is a precomputed hash of the key
3678 const char *keypv, STRLEN keylen, U32 hash, U32 flags)
3723 if (!hash)
3724 PERL_HASH(hash, keypv, keylen);
3729 hash == chain->refcounted_he_hash &&
3734 hash == HEK_HASH(chain->refcounted_he_hek) &&
3762 const char *key, U32 hash, U32 flags)
3765 return refcounted_he_fetch_pvn(chain, key, strlen(key), hash, flags);
3779 SV *key, U32 hash, U32 flags)
3790 if (!hash && SvIsCOW_shared_hash(key))
3791 hash = SvSHARED_HASH(key);
3792 return refcounted_he_fetch_pvn(chain, keypv, keylen, hash, flags);
3806 as UTF-8, otherwise they are interpreted as Latin-1. C<hash> is
3807 a precomputed hash of the key string, or zero if it has not been
3830 const char *keypv, STRLEN keylen, U32 hash, SV *value, U32 flags)
3899 if (!hash)
3900 PERL_HASH(hash, keypv, keylen);
3925 he->refcounted_he_hash = hash;
3929 he->refcounted_he_hek = share_hek_flags(keypv, keylen, hash, hekflags);
3949 const char *key, U32 hash, SV *value, U32 flags)
3952 return refcounted_he_new_pvn(parent, key, strlen(key), hash, value, flags);
3966 SV *key, U32 hash, SV *value, U32 flags)
3977 if (!hash && SvIsCOW_shared_hash(key))
3978 hash = SvSHARED_HASH(key);
3979 return refcounted_he_new_pvn(parent, keypv, keylen, hash, value, flags);
4125 Check that a hash is in an internally consistent state.
4160 "hash key has both WASUTF8 and UTF8: '%.*s'\n",
4168 static const char bad_count[] = "Count %d %s(s), but hash reports %d\n";
4190 HvRITER_set(hv, riter); /* Restore hash iterator state */