couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [19/25] couch commit: updated refs/heads/master to 92598cd
Date Thu, 15 Oct 2015 16:35:53 GMT
Use decode_attributes in len_doc_to_multi_part_stream


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

Branch: refs/heads/master
Commit: 07902029dfdc2ac595d635ace5514fab502f40c3
Parents: 4fead90
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Fri Nov 28 13:34:20 2014 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Wed May 6 06:55:59 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/07902029/src/couch_doc.erl
----------------------------------------------------------------------
diff --git a/src/couch_doc.erl b/src/couch_doc.erl
index e16d0a7..3669865 100644
--- a/src/couch_doc.erl
+++ b/src/couch_doc.erl
@@ -353,25 +353,12 @@ merge_stubs(#doc{id=Id,atts=MemBins}=StubsDoc, #doc{atts=DiskBins})
->
 
 len_doc_to_multi_part_stream(Boundary, JsonBytes, Atts, SendEncodedAtts) ->
     AttsToInclude = lists:filter(fun(Att) -> not couch_att:is_stub(Att) end, Atts),
-    AttsSize = lists:foldl(fun(Att, AccAttsSize) ->
-            [Data, Name, AttLen, DiskLen, Type, Encoding] =
-                 couch_att:fetch([data, name, att_len, disk_len, type, encoding], Att),
-            case Data of
-            stub ->
-                not_reachable = AccAttsSize;
-            _ ->
+    AttsDecoded = decode_attributes(AttsToInclude, SendEncodedAtts),
+    AttsSize = lists:foldl(fun({_Att, Name, Len, Type, Encoding}, AccAttsSize) ->
                 AccAttsSize +
                 4 + % "\r\n\r\n"
-                case SendEncodedAtts of
-                true ->
-                    % header
-                    length(integer_to_list(AttLen)) +
-                    AttLen;
-                _ ->
-                    % header
-                    length(integer_to_list(DiskLen)) +
-                    DiskLen
-                end +
+                length(integer_to_list(Len)) +
+                Len +
                 4 + % "\r\n--"
                 size(Boundary) +
 
@@ -389,8 +376,7 @@ len_doc_to_multi_part_stream(Boundary, JsonBytes, Atts, SendEncodedAtts)
->
                     length(atom_to_list(Encoding)) +
                     length("\r\nContent-Encoding: ")
                 end
-            end
-        end, 0, AttsToInclude),
+        end, 0, AttsDecoded),
     if AttsSize == 0 ->
         {<<"application/json">>, iolist_size(JsonBytes)};
     true ->


Mime
View raw message