This is an automated email from the ASF dual-hosted git repository.

iilyak pushed a commit to branch couch-stats-resource-tracker-http-api
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 49d247f3f74c0803af39a2cfce805f2c7153a285
Author: ILYA Khlopotov <[email protected]>
AuthorDate: Tue Jun 10 12:05:16 2025 -0700

    Replace comparison with pattern match.
---
 src/couch_stats/src/csrt_query.erl | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/couch_stats/src/csrt_query.erl 
b/src/couch_stats/src/csrt_query.erl
index a813b4c45..62b03d695 100644
--- a/src/couch_stats/src/csrt_query.erl
+++ b/src/couch_stats/src/csrt_query.erl
@@ -136,13 +136,11 @@ group_by(KeyFun, ValFun, AggFun) ->
         Key = KeyFun(Ele),
         Val = ValFun(Ele),
         CurrVal = maps:get(Key, Acc, 0),
-        NewVal = AggFun(CurrVal, Val),
-        %% TODO: should we skip here? how to make this optional?
-        case NewVal > 0 of
-            true ->
-                maps:put(Key, NewVal, Acc);
-            false ->
-                Acc
+        case AggFun(CurrVal, Val) of
+            0 ->
+                Acc;
+            NewVal ->
+                maps:put(Key, NewVal, Acc)
         end
     end,
     ets:foldl(FoldFun, #{}, ?CSRT_ETS).

Reply via email to