aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_term.h
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-10-20 06:11:04 +0200
committerBjörn Gustavsson <[email protected]>2017-10-21 07:50:12 +0200
commit6753bbcc3fdb0dd15c8025902d22dc4ec8c33575 (patch)
treecc84ad335e0018b9572e777756f9f6876787e893 /erts/emulator/beam/erl_term.h
parent3ea750a53874d61ef7d4d806656ca63c7759a8a4 (diff)
downloadotp-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 'erts/emulator/beam/erl_term.h')
0 files changed, 0 insertions, 0 deletions