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


##########
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:
   I think the only place we use this is in mango:
   
   
https://github.com/apache/couchdb/blob/420a577ace6a59a0febc20de6b4195f1754fc358/src/mango/src/mango_cursor_view.erl#L684
   
   And there if we don't have the value set we already check in the case 
statement surrounding so it should be fine?



##########
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:
   I think the only other place we use this is in mango:
   
   
https://github.com/apache/couchdb/blob/420a577ace6a59a0febc20de6b4195f1754fc358/src/mango/src/mango_cursor_view.erl#L684
   
   And there if we don't have the value set we already check in the case 
statement surrounding so it should be fine?



-- 
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