nickva commented on code in PR #5588:
URL: https://github.com/apache/couchdb/pull/5588#discussion_r2190520337


##########
src/couch/src/couch_util.erl:
##########
@@ -228,8 +228,14 @@ get_value(Key, List, Default) ->
             Default
     end.
 
-set_value(Key, List, Value) ->
-    lists:keyreplace(Key, 1, List, {Key, Value}).
+% insert or update a {Key, Value} tuple in a list of tuples
+-spec set_value(Key, TupleList1, Value) -> TupleList2 when
+    Key :: term(),
+    TupleList1 :: [Tuple],
+    Value :: any(),
+    TupleList2 :: [Tuple].
+set_value(Key, TupleList1, Value) ->
+    lists:keystore(Key, 1, TupleList1, {Key, Value}).

Review Comment:
   This is kind of a surprising behavior from the previous code. If they key 
wasn't there at all, we never set it, if I read the keyreplace docs correctly?. 
It's good to fix, definitely.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to