Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add hashval() implementation to FIA for faster, more efficient hashing

  • Loading branch information...
commit f3c2cd19dc5b731f4247614c50db4416518b6a91 1 parent 3faf240
@plobsing plobsing authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 src/pmc/fixedintegerarray.pmc
View
23 src/pmc/fixedintegerarray.pmc
@@ -299,6 +299,29 @@ Returns the Parrot string representation C<key>.
/*
+=item C<INTVAL hashvalue()>
+
+Get a hashvalue for this PMC.
+
+Providing a non-default C<hashvalue()> implementation avoids creating
+unecessary string temporaries.
+
+=cut
+
+*/
+
+ VTABLE INTVAL hashvalue() {
+ INTVAL *int_array;
+ INTVAL size;
+ GET_ATTR_int_array(INTERP, SELF, int_array);
+ GET_ATTR_size(INTERP, SELF, size);
+ return Parrot_hsh_hash_buffer((const unsigned char *)int_array,
+ size * sizeof (INTVAL), INTERP->hash_seed);
+ }
+
+
+/*
+
=item C<STRING *get_string_keyed(PMC *key)>
Returns the Parrot string value of the element at index C<*key>.
Please sign in to comment.
Something went wrong with that request. Please try again.