aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2013-03-15 11:59:45 +0100
committerBjörn-Egil Dahlberg <[email protected]>2013-04-30 17:05:33 +0200
commit26849296883df7517af7d474210c343c943b48e2 (patch)
tree122f0e2041fce186e9fda9e1331390a6e49be5ad /erts
parentcda401b58a3db7213eb14197680d401fd1399de9 (diff)
downloadotp-26849296883df7517af7d474210c343c943b48e2.tar.gz
otp-26849296883df7517af7d474210c343c943b48e2.tar.bz2
otp-26849296883df7517af7d474210c343c943b48e2.zip
erts: Use fast path for list_to_binary([Bin]) case
A common case is to wrap an argument to list_to_binary in a list to ensure conversion can happen even though the argument may already be a binary. Use fast path for this case.
Diffstat (limited to 'erts')
-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;