diff options
author | Raimo Niskanen <[email protected]> | 2019-07-03 11:47:57 +0200 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2019-07-03 11:47:57 +0200 |
commit | bf0f197f566b688df0e0c6a5a343019643732d86 (patch) | |
tree | f24c634cc140a80f4bbd4a23a75c230bbf487c6e /lib/ssl/src/ssl_connection.erl | |
parent | 54e8284d883b11a83ec48edb41c9a15d657bae8e (diff) | |
download | otp-bf0f197f566b688df0e0c6a5a343019643732d86.tar.gz otp-bf0f197f566b688df0e0c6a5a343019643732d86.tar.bz2 otp-bf0f197f566b688df0e0c6a5a343019643732d86.zip |
Refine the queue code
Diffstat (limited to 'lib/ssl/src/ssl_connection.erl')
-rw-r--r-- | lib/ssl/src/ssl_connection.erl | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl index af9f0cbf3a..b3b1dc18dc 100644 --- a/lib/ssl/src/ssl_connection.erl +++ b/lib/ssl/src/ssl_connection.erl @@ -673,7 +673,18 @@ read_application_dist_data(DHandle, Front0, BufferSize, Rear0, Bin0) -> iovec_from_front(0, Front, Rear, Acc) -> {lists:reverse(Acc),Front,Rear}; iovec_from_front(Size, [], Rear, Acc) -> - iovec_from_front(Size, lists:reverse(Rear), [], Acc); + case Rear of + %% Avoid lists:reverse/1 for simple cases. + %% Case clause for [] to avoid infinite loop. + [_] -> + iovec_from_front(Size, Rear, [], Acc); + [Bin2,Bin1] -> + iovec_from_front(Size, [Bin1,Bin2], [], Acc); + [Bin3,Bin2,Bin1] -> + iovec_from_front(Size, [Bin1,Bin2,Bin3], [], Acc); + [_,_,_|_] = Rear -> + iovec_from_front(Size, lists:reverse(Rear), [], Acc) + end; iovec_from_front(Size, [Bin|Front], Rear, Acc) -> case Bin of <<Last:Size/binary>> -> % Just enough |