diff options
author | Björn Gustavsson <[email protected]> | 2017-10-20 06:11:04 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-10-21 07:50:12 +0200 |
commit | 6753bbcc3fdb0dd15c8025902d22dc4ec8c33575 (patch) | |
tree | cc84ad335e0018b9572e777756f9f6876787e893 /lib/cosEvent | |
parent | 3ea750a53874d61ef7d4d806656ca63c7759a8a4 (diff) | |
download | otp-6753bbcc3fdb0dd15c8025902d22dc4ec8c33575.tar.gz otp-6753bbcc3fdb0dd15c8025902d22dc4ec8c33575.tar.bz2 otp-6753bbcc3fdb0dd15c8025902d22dc4ec8c33575.zip |
Optimize matching of literals for single-valued types
If a type only has one clause and if the pattern is literal,
the matching can be done more efficiently by directly comparing
with the literal.
Example:
find(String, "") -> String;
find(String, <<>>) -> String;
find(String, SearchPattern) ->
.
.
.
Without this optimization, the relevant part of the code would look
this:
{test,bs_start_match2,{f,3},2,[{x,1},0],{x,2}}.
{test,bs_test_tail2,{f,4},[{x,2},0]}.
return.
{label,3}.
{test,is_nil,{f,4},[{x,1}]}.
return.
{label,4}.
.
.
.
That is, if {x,1} is a binary, a match context will be built to
test whether {x,1} is an empty binary.
With the optimization, the code will look this:
{test,is_eq_exact,{f,3},[{x,1},{literal,<<>>}]}.
return.
{label,3}.
{test,is_nil,{f,4},[{x,1}]}.
return.
{label,4}.
.
.
.
Diffstat (limited to 'lib/cosEvent')
0 files changed, 0 insertions, 0 deletions