LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0505-erts-Fix-lists_member_2-reduction-count.patch of Package erlang (Project home:Ledest:erlang:20)

From 790aa06d380b5842fe2fdd984bdde4f160b3adaa Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 24 Oct 2018 17:08:03 +0200
Subject: [PATCH] erts: Fix lists_member_2 reduction count

OTP-15474
---
 erts/emulator/beam/erl_bif_lists.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/erts/emulator/beam/erl_bif_lists.c b/erts/emulator/beam/erl_bif_lists.c
index 395be67a90..2a2b94c831 100644
--- a/erts/emulator/beam/erl_bif_lists.c
+++ b/erts/emulator/beam/erl_bif_lists.c
@@ -249,7 +249,8 @@ BIF_RETTYPE lists_member_2(BIF_ALIST_2)
     Eterm list;
     Eterm item;
     int non_immed_key;
-    int max_iter = 10 * CONTEXT_REDS;
+    int reds_left = ERTS_BIF_REDS_LEFT(BIF_P);
+    int max_iter = 16 * reds_left;
 
     if (is_nil(BIF_ARG_2)) {
 	BIF_RET(am_false);
@@ -267,14 +268,15 @@ BIF_RETTYPE lists_member_2(BIF_ALIST_2)
 	}
 	item = CAR(list_val(list));
 	if ((item == term) || (non_immed_key && eq(item, term))) {
-	    BIF_RET2(am_true, CONTEXT_REDS - max_iter/10);
+	    BIF_RET2(am_true, reds_left - max_iter/16);
 	}
 	list = CDR(list_val(list));
     }
     if (is_not_nil(list))  {
+        BUMP_REDS(BIF_P, reds_left - max_iter/16);
 	BIF_ERROR(BIF_P, BADARG);
     }
-    BIF_RET2(am_false, CONTEXT_REDS - max_iter/10);
+    BIF_RET2(am_false, reds_left - max_iter/16);
 }
 
 static BIF_RETTYPE lists_reverse_alloc(Process *c_p,
-- 
2.16.4