[erlang-patches] [PATCH] - Add NIF function enif_phash2
Thu Feb 14 15:25:43 CET 2013
On 02/08/2013 09:19 PM, Paul Davis wrote:
> Rebased against master:
> git fetch git://github.com/davisp/otp.git enif_phash2
> I've updated the function ordering as per the comment in
> erl_nif_api_funcs.h. For use case, I'm implementing a couple data
> structures that use hash tables to speed up some hot loops. I can get
> away for awhile using erlang:phash2/2 in Erlang and passing that value
> into the NIF but this breaks down when I don't know a priori which
> terms (or subterms) I may need to hash in the NIF.
> A similar example would be trying to reimplement ets without this.
> Either I'd have to store enough information in the Erlang term
> representing the table to be able to know which elements of the tuple
> to hash or I'd have to ask the table what to hash before passing the
> term off to the NIF. There are definitely work arounds to not having
> access to phash2 but they aren't pretty.
> Paul Davis
> On Fri, Feb 8, 2013 at 7:39 AM, Sverker Eriksson
> <> wrote:
>> Fredrik wrote:
>>> On 02/08/2013 12:58 AM, Paul Davis wrote:
>>>> git fetch git://github.com/davisp/otp.git enif_phash2
>>>> This patch exposes the phash2 function to NIFs. It is exactly equivalent
>>>> erlang:phash2(Term, 16#100000000)
>>>> Paul Davis
>>>> erlang-patches mailing list
>>> Please rebase this patch upon the current 'master' branch.
>> Also read the comments in erl_nif_api_funcs.h of how to add new functions.
>> You do not have to increase ERL_NIF_MINOR_VERSION as I've already done that
>> for R16B.
>> I guess you have a real use case for enif_phash2 and why erlang:phash2 is
>> not enough.
Hello could you rebase this upon the current 'master' branch on github
BR Fredrik Gustafsson
Erlang OTP Team
More information about the erlang-patches