File 4641-erl_lint-Recurse-with-cheaper-function-in-pattern-ch.patch of Package erlang
From 9218bd59fdc5948c43ccd0f0e45f1edb1143129d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Muska=C5=82a?= <micmus@fb.com>
Date: Mon, 3 Apr 2023 18:09:32 +0100
Subject: [PATCH] [erl_lint] Recurse with cheaper function in pattern checks
I noticed lists were recursed with the is_pattern_expr_1/1 function,
while tuples were recursed with the more expensive (since it's also
doing an eval) is_pattern_expr/1 function. Since there will be an
eval at the end anyway, I don't see a reason for this difference.
This makes it so that all internall recursion is using the cheaper
function.
---
lib/stdlib/src/erl_lint.erl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl
index f8d629c02c..a4833f940b 100644
--- a/lib/stdlib/src/erl_lint.erl
+++ b/lib/stdlib/src/erl_lint.erl
@@ -1796,14 +1796,14 @@ is_pattern_expr_1({integer,_Anno,_I}) -> true;
is_pattern_expr_1({float,_Anno,_F}) -> true;
is_pattern_expr_1({atom,_Anno,_A}) -> true;
is_pattern_expr_1({tuple,_Anno,Es}) ->
- all(fun is_pattern_expr/1, Es);
+ all(fun is_pattern_expr_1/1, Es);
is_pattern_expr_1({nil,_Anno}) -> true;
is_pattern_expr_1({cons,_Anno,H,T}) ->
is_pattern_expr_1(H) andalso is_pattern_expr_1(T);
is_pattern_expr_1({op,_Anno,Op,A}) ->
erl_internal:arith_op(Op, 1) andalso is_pattern_expr_1(A);
is_pattern_expr_1({op,_Anno,Op,A1,A2}) ->
- erl_internal:arith_op(Op, 2) andalso all(fun is_pattern_expr/1, [A1,A2]);
+ erl_internal:arith_op(Op, 2) andalso all(fun is_pattern_expr_1/1, [A1,A2]);
is_pattern_expr_1(_Other) -> false.
pattern_map(Ps, Vt0, Old, St0) ->
--
2.35.3