[erlang-questions] process dictionary and get_keys/1

Ulf Wiger ulf@REDACTED
Tue Aug 6 19:11:28 CEST 2013


True, I guess I was a bit sloppy when I tried it in different OTP versions.
It even exists in R13B… :)

A slightly slower linear search on process dictionaries, but more flexible, and still faster than searching a gb_trees or dict structure, is:

select_keys(V) ->
    MS = ets:match_spec_compile([{{'$1',V}, [], ['$1']}]),
    ets:match_spec_run(get(), MS).

About the same speed as doing a list comprehension using get() as generator, and faster than putting the same data in ets and using ets:select/2.

BR,
Ulf

On 6 Aug 2013, at 15:47, Lukas Larsson <lukas@REDACTED> wrote:

> 
> 
> On Tue, Aug 6, 2013 at 3:35 PM, Ulf Wiger <ulf@REDACTED> wrote:
> 
> 
> Can anyone shed some light on why it was introduced in the first place?
> 
> Not sure from where you got that it was added in R15B, from what I can gather it has always been there, at least since R4B[1]. It has not been overly used though it seems :)
> 
> [1]: http://www.erlang.org/documentation/doc-4.7.3/lib/kernel-2.1.1/doc/html/erlang.html

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130806/302c87d1/attachment.htm>


More information about the erlang-questions mailing list