aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/io.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-09-01 17:37:04 +0200
committerBjörn Gustavsson <[email protected]>2015-11-09 15:38:50 +0100
commite59290283c595efa84c8ac7720eb128dedb98fce (patch)
tree76863a0985f34dffa609dfb86bec79045ce3943c /lib/stdlib/src/io.erl
parentce4ba8d71fe41fa827f35f8c75917d76125fa8ab (diff)
downloadotp-e59290283c595efa84c8ac7720eb128dedb98fce.tar.gz
otp-e59290283c595efa84c8ac7720eb128dedb98fce.tar.bz2
otp-e59290283c595efa84c8ac7720eb128dedb98fce.zip
io: Make a fast code path for i/o requests
Unicode support was introduced in R13. The backward compatible code path in 'io' is unlikely to be used in practice. Therefore, make sure that the common case of an i/o server supporting unicode requests is as fast as possible, making sure to get rid of the mathing and re-building of tuples in the current code. Make the backward compatible code path work with a minimum of code.
Diffstat (limited to 'lib/stdlib/src/io.erl')
-rw-r--r--lib/stdlib/src/io.erl43
1 files changed, 11 insertions, 32 deletions
diff --git a/lib/stdlib/src/io.erl b/lib/stdlib/src/io.erl
index 284f2e5a2b..5dc8b4541e 100644
--- a/lib/stdlib/src/io.erl
+++ b/lib/stdlib/src/io.erl
@@ -631,41 +631,20 @@ io_requests(Pid, [], [Rs|Cont], Tail) ->
io_requests(_Pid, [], [], _Tail) ->
{false,[]}.
-
-bc_req(Pid,{Op,Enc,Param},MaybeConvert) ->
- case net_kernel:dflag_unicode_io(Pid) of
- true ->
- {false,{Op,Enc,Param}};
- false ->
- {MaybeConvert,{Op,Param}}
- end;
-bc_req(Pid,{Op,Enc,P,F},MaybeConvert) ->
- case net_kernel:dflag_unicode_io(Pid) of
- true ->
- {false,{Op,Enc,P,F}};
- false ->
- {MaybeConvert,{Op,P,F}}
- end;
-bc_req(Pid, {Op,Enc,M,F,A},MaybeConvert) ->
+bc_req(Pid, Req0, MaybeConvert) ->
case net_kernel:dflag_unicode_io(Pid) of
true ->
- {false,{Op,Enc,M,F,A}};
+ %% The most common case. A modern i/o server.
+ {false,Req0};
false ->
- {MaybeConvert,{Op,M,F,A}}
- end;
-bc_req(Pid, {Op,Enc,P,M,F,A},MaybeConvert) ->
- case net_kernel:dflag_unicode_io(Pid) of
- true ->
- {false,{Op,Enc,P,M,F,A}};
- false ->
- {MaybeConvert,{Op,P,M,F,A}}
- end;
-bc_req(Pid,{Op,Enc},MaybeConvert) ->
- case net_kernel:dflag_unicode_io(Pid) of
- true ->
- {false,{Op, Enc}};
- false ->
- {MaybeConvert,Op}
+ %% Backward compatibility only. Unlikely to ever happen.
+ case tuple_to_list(Req0) of
+ [Op,_Enc] ->
+ {MaybeConvert,Op};
+ [Op,_Enc|T] ->
+ Req = list_to_tuple([Op|T]),
+ {MaybeConvert,Req}
+ end
end.
io_request(Pid, {write,Term}) ->