Hey Adam, Hum, didn't notice before that only the first occurrence is stored with lists:keystore/4. My fault :(
I'll revert it. cheers On Mon, Jul 12, 2010 at 5:44 PM, Adam Kocoloski <[email protected]> wrote: > 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}, > > > > > > -- Filipe David Manana, [email protected] "Reasonable men adapt themselves to the world. Unreasonable men adapt the world to themselves. That's why all progress depends on unreasonable men."
