The is_record() guard

Steve Davis <>
Thu Jul 23 19:20:57 CEST 2009


I have an application that uses records extensively. At one point in
processing these records I have a match function:

transform(R) when is_record(R, rec_a) -> ... ;
transform(R) when is_record(R, rec_b) -> ... ;
transform(R) when is_record(R, rec_c) -> ... ;
...

A first run of fprof appears to show that this function match is
bottlenecking (noticeably so, but not in dire fashion).

I'm planning a comparative run using transform(element(1, R), R) as
the call signature:

transform(rec_a, R) -> ...;
transform(rec_b, R) -> ...;
transform(rec_c, R) -> ...;
....

However - before I refactor, does anybody happen to know whether this
performance hit would this be expected?

Is the is_record guard known to be slow/heavy in some way?

Regards,
/sd


More information about the erlang-questions mailing list