Hi Filipe, I thought about doing this once, but lists:keystore/4 only drops the first occurrence of K, whereas json_apply_field drops all matching occurrences. Do we care about the case where multiple values for e.g. the Vary header have been supplied by the user in a show function?
Adam On Jul 11, 2010, at 6:31 AM, [email protected] wrote: > Author: fdmanana > Date: Sun Jul 11 10:31:38 2010 > New Revision: 963042 > > URL: http://svn.apache.org/viewvc?rev=963042&view=rev > Log: > Removing unnecessary code. > > 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=963042&r1=963041&r2=963042&view=diff > ============================================================================== > --- couchdb/trunk/src/couchdb/couch_util.erl (original) > +++ couchdb/trunk/src/couchdb/couch_util.erl Sun Jul 11 10:31:38 2010 > @@ -144,18 +144,11 @@ get_nested_json_value(Value, []) -> > get_nested_json_value(_NotJSONObj, _) -> > throw({not_found, json_mismatch}). > > -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]}. > +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)}. > > json_user_ctx(#db{name=DbName, user_ctx=Ctx}) -> > {[{<<"db">>, DbName}, > >
