couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [15/25] couch commit: updated refs/heads/master to 92598cd
Date Thu, 15 Oct 2015 16:35:49 GMT
Do not calculate AttFun for every att since we use same function for all atts in the doc


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/f99d3bab
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/f99d3bab
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/f99d3bab

Branch: refs/heads/master
Commit: f99d3bab3dda424e767fee583f25c36610724c6c
Parents: 8ef360f
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Fri Nov 28 10:59:18 2014 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Wed May 6 06:55:58 2015 -0700

----------------------------------------------------------------------
 src/couch_doc.erl | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f99d3bab/src/couch_doc.erl
----------------------------------------------------------------------
diff --git a/src/couch_doc.erl b/src/couch_doc.erl
index 494ec53..c43d6a1 100644
--- a/src/couch_doc.erl
+++ b/src/couch_doc.erl
@@ -417,15 +417,19 @@ doc_to_multi_part_stream(Boundary, JsonBytes, Atts, WriteFun,
           end,
         {Att, Name, Len, Type, Encoding}
       end, AttsToInclude),
-    encode_multipart_stream(Boundary, JsonBytes, AttsDecoded, WriteFun, SendEncodedAtts).
+    AttFun = case SendEncodedAtts of
+        false -> fun couch_att:foldl_decode/3;
+        true  -> fun couch_att:foldl/3
+    end,
+    encode_multipart_stream(Boundary, JsonBytes, AttsDecoded, WriteFun, AttFun).
 
-atts_to_mp([], _Boundary, WriteFun, _SendEncAtts) ->
+atts_to_mp([], _Boundary, WriteFun, _AttFun) ->
     WriteFun(<<"--">>);
 atts_to_mp([{Att, Name, LengthBin, Type, Encoding} | RestAtts], Boundary, WriteFun,
-    SendEncodedAtts)  ->
+    AttFun)  ->
     case couch_att:is_stub(Att) of
         true ->
-            unreacheable = atts_to_mp(RestAtts, Boundary, WriteFun, SendEncodedAtts);
+            unreacheable = atts_to_mp(RestAtts, Boundary, WriteFun, AttFun);
         false ->
             % write headers
             WriteFun(<<"\r\nContent-Disposition: attachment; filename=\"", Name/binary,
"\"">>),
@@ -441,22 +445,18 @@ atts_to_mp([{Att, Name, LengthBin, Type, Encoding} | RestAtts], Boundary,
WriteF
 
             % write data
             WriteFun(<<"\r\n\r\n">>),
-            AttFun = case SendEncodedAtts of
-                false -> fun couch_att:foldl_decode/3;
-                true  -> fun couch_att:foldl/3
-            end,
             AttFun(Att, fun(Data, _) -> WriteFun(Data) end, ok),
             WriteFun(<<"\r\n--", Boundary/binary>>),
-            atts_to_mp(RestAtts, Boundary, WriteFun, SendEncodedAtts)
+            atts_to_mp(RestAtts, Boundary, WriteFun, AttFun)
     end.
 
-encode_multipart_stream(_Boundary, JsonBytes, [], WriteFun, _SendEncodedAtts) ->
+encode_multipart_stream(_Boundary, JsonBytes, [], WriteFun, _AttFun) ->
     WriteFun(JsonBytes);
-encode_multipart_stream(Boundary, JsonBytes, Atts, WriteFun, SendEncodedAtts) ->
+encode_multipart_stream(Boundary, JsonBytes, Atts, WriteFun, AttFun) ->
     WriteFun([<<"--", Boundary/binary,
                 "\r\nContent-Type: application/json\r\n\r\n">>,
               JsonBytes, <<"\r\n--", Boundary/binary>>]),
-    atts_to_mp(Atts, Boundary, WriteFun, SendEncodedAtts).
+    atts_to_mp(Atts, Boundary, WriteFun, AttFun).
 
 doc_from_multi_part_stream(ContentType, DataFun) ->
     doc_from_multi_part_stream(ContentType, DataFun, make_ref()).


Mime
View raw message