pgj commented on code in PR #4812:
URL: https://github.com/apache/couchdb/pull/4812#discussion_r1413085196
##########
src/rexi/src/rexi.erl:
##########
@@ -328,3 +336,23 @@ drain_acks(Count) ->
after 0 ->
{ok, Count}
end.
+
+get_delta() ->
+ {delta, couch_stats_resource_tracker:make_delta()}.
+
+maybe_add_delta(T) ->
+ case couch_stats_resource_tracker:is_enabled() of
+ false ->
+ T;
+ true ->
+ add_delta(T, get_delta())
+ end.
+
+add_delta({A}, Delta) -> {A, Delta};
Review Comment:
The same could be expressed with the help of `erlang:insert_element/3` and
`erlang:size/1`:
```erlang
add_delta(T, Delta) -> erlang:insert_element(erlang:size(T) + 1, T, Delta).
```
If maximum tuple size matters (semantically equivalent):
```erlang
add_delta(T, Delta) when 0 < erlang:size(T), erlang:size(T) < 8 ->
erlang:insert_element(erlang:size(T) + 1, T, Delta);
add_delta(T, _Delta) -> T.
```
--
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]