couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r963367 - /couchdb/trunk/src/couchdb/couch_util.erl
Date Mon, 12 Jul 2010 17:24:01 GMT
Author: fdmanana
Date: Mon Jul 12 17:24:00 2010
New Revision: 963367

URL: http://svn.apache.org/viewvc?rev=963367&view=rev
Log:
Reverting revision 963042 - lists:keystore/4 only replaces the first occurrence in the list.

Modified:
    couchdb/trunk/src/couchdb/couch_util.erl

Modified: couchdb/trunk/src/couchdb/couch_util.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_util.erl?rev=963367&r1=963366&r2=963367&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_util.erl (original)
+++ couchdb/trunk/src/couchdb/couch_util.erl Mon Jul 12 17:24:00 2010
@@ -144,11 +144,18 @@ get_nested_json_value(Value, []) ->
 get_nested_json_value(_NotJSONObj, _) ->
     throw({not_found, json_mismatch}).
 
-proplist_apply_field({K, _V} = KV, L) ->
-    lists:keystore(K, 1, L, KV).
-
-json_apply_field({K, _V} = KV, {L}) ->
-    {lists:keystore(K, 1, L, KV)}.
+proplist_apply_field(H, L) ->
+    {R} = json_apply_field(H, {L}),
+    R.
+
+json_apply_field(H, {L}) ->
+    json_apply_field(H, L, []).
+json_apply_field({Key, NewValue}, [{Key, _OldVal} | Headers], Acc) ->
+    json_apply_field({Key, NewValue}, Headers, Acc);
+json_apply_field({Key, NewValue}, [{OtherKey, OtherVal} | Headers], Acc) ->
+    json_apply_field({Key, NewValue}, Headers, [{OtherKey, OtherVal} | Acc]);
+json_apply_field({Key, NewValue}, [], Acc) ->
+    {[{Key, NewValue}|Acc]}.
 
 json_user_ctx(#db{name=DbName, user_ctx=Ctx}) ->
     {[{<<"db">>, DbName},



Mime
View raw message