Author: fdmanana Date: Mon Jan 17 11:30:48 2011 New Revision: 1059884 URL: http://svn.apache.org/viewvc?rev=1059884&view=rev Log: Removed unnecessary iolist_to_binary/1 calls
These IOlist to binary conversions are not necessary since ibrowse accepts IOlists as outputs of streaming functions. Also, having the IOlists getting converted into binaries by the erts (instead of user Erlang code) is more efficient. Modified: couchdb/trunk/src/couchdb/couch_httpd_proxy.erl Modified: couchdb/trunk/src/couchdb/couch_httpd_proxy.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_proxy.erl?rev=1059884&r1=1059883&r2=1059884&view=diff ============================================================================== --- couchdb/trunk/src/couchdb/couch_httpd_proxy.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd_proxy.erl Mon Jan 17 11:30:48 2011 @@ -145,7 +145,7 @@ stream_chunked_body({stream, MReq, 0, Bu {CRem, Data} = read_chunk_length(MReq), case CRem of 0 -> - BodyData = iolist_to_binary(lists:reverse(Buf, Data)), + BodyData = lists:reverse(Buf, Data), {ok, BodyData, {trailers, MReq, [], ?PKT_SIZE}}; _ -> stream_chunked_body( @@ -154,7 +154,7 @@ stream_chunked_body({stream, MReq, 0, Bu end; stream_chunked_body({stream, MReq, CRem, Buf, BRem}) when BRem =< 0 -> % Time to empty our buffers to the upstream socket. - BodyData = iolist_to_binary(lists:reverse(Buf)), + BodyData = lists:reverse(Buf), {ok, BodyData, {stream, MReq, CRem, [], ?PKT_SIZE}}; stream_chunked_body({stream, MReq, CRem, Buf, BRem}) -> % Buffer some more data from the client. @@ -176,7 +176,7 @@ stream_chunked_body({stream, MReq, CRem, stream_chunked_body(NewState); stream_chunked_body({trailers, MReq, Buf, BRem}) when BRem =< 0 -> % Empty our buffers and send data upstream. - BodyData = iolist_to_binary(lists:reverse(Buf)), + BodyData = lists:reverse(Buf), {ok, BodyData, {trailers, MReq, [], ?PKT_SIZE}}; stream_chunked_body({trailers, MReq, Buf, BRem}) -> % Read another trailer into the buffer or stop on an @@ -186,7 +186,7 @@ stream_chunked_body({trailers, MReq, Buf case mochiweb_socket:recv(Socket, 0, ?TIMEOUT) of {ok, <<"\r\n">>} -> mochiweb_socket:setopts(Socket, [{packet, raw}]), - BodyData = iolist_to_binary(lists:reverse(Buf, <<"\r\n">>)), + BodyData = lists:reverse(Buf, <<"\r\n">>), {ok, BodyData, eof}; {ok, Footer} -> mochiweb_socket:setopts(Socket, [{packet, raw}]),