aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2013-05-03 15:24:56 +0200
committerBjörn-Egil Dahlberg <[email protected]>2013-05-03 15:24:56 +0200
commit0dc5a00011d1d24b68c9d43ff608415f84c50499 (patch)
treefb7f797a207528912c00c19266de9802fdfe6ac2 /erts/emulator/beam
parentb306fa57d3f78b86fea04438483e2d34fcb91d0e (diff)
parent26849296883df7517af7d474210c343c943b48e2 (diff)
downloadotp-0dc5a00011d1d24b68c9d43ff608415f84c50499.tar.gz
otp-0dc5a00011d1d24b68c9d43ff608415f84c50499.tar.bz2
otp-0dc5a00011d1d24b68c9d43ff608415f84c50499.zip
Merge branch 'egil/opt-list_to_binary/OTP-11082'
* egil/opt-list_to_binary/OTP-11082: erts: Use fast path for list_to_binary([Bin]) case
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/binary.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/erts/emulator/beam/binary.c b/erts/emulator/beam/binary.c
index 33abac2f3d..c7926f18af 100644
--- a/erts/emulator/beam/binary.c
+++ b/erts/emulator/beam/binary.c
@@ -447,6 +447,7 @@ BIF_RETTYPE bitstring_to_list_1(BIF_ALIST_1)
BIF_RETTYPE erts_list_to_binary_bif(Process *p, Eterm arg)
{
Eterm bin;
+ Eterm h,t;
ErlDrvSizeT size;
byte* bytes;
#ifdef DEBUG
@@ -459,6 +460,16 @@ BIF_RETTYPE erts_list_to_binary_bif(Process *p, Eterm arg)
if (is_not_list(arg)) {
goto error;
}
+ /* check for [binary()] case */
+ h = CAR(list_val(arg));
+ t = CDR(list_val(arg));
+ if (is_binary(h) && is_nil(t) && !(
+ HEADER_SUB_BIN == *(binary_val(h)) && (
+ ((ErlSubBin *)binary_val(h))->bitoffs != 0 ||
+ ((ErlSubBin *)binary_val(h))->bitsize != 0
+ ))) {
+ return h;
+ }
switch (erts_iolist_size(arg, &size)) {
case ERTS_IOLIST_OVERFLOW: BIF_ERROR(p, SYSTEM_LIMIT);
case ERTS_IOLIST_TYPE: goto error;