* [PATCH] enum.c: remove volatile, use RB_GC_GUARD
@ 2015-06-23 3:02 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-06-23 3:02 UTC (permalink / raw)
To: spew
volatile appears unnecessary in most cases as the VALUEs are used as
arguments of uninlined functions. Even worse, volatile can be
insufficient in places where RB_GC_GUARD is necessary.
---
enum.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/enum.c b/enum.c
index 4b1e119..8a3a463 100644
--- a/enum.c
+++ b/enum.c
@@ -2351,10 +2351,10 @@ static VALUE
zip_ary(RB_BLOCK_CALL_FUNC_ARGLIST(val, memoval))
{
struct MEMO *memo = (struct MEMO *)memoval;
- volatile VALUE result = memo->v1;
- volatile VALUE args = memo->v2;
+ VALUE result = memo->v1;
+ VALUE args = memo->v2;
long n = memo->u3.cnt++;
- volatile VALUE tmp;
+ VALUE tmp;
int i;
tmp = rb_ary_new2(RARRAY_LEN(args) + 1);
@@ -2375,6 +2375,9 @@ zip_ary(RB_BLOCK_CALL_FUNC_ARGLIST(val, memoval))
else {
rb_ary_push(result, tmp);
}
+
+ RB_GC_GUARD(args);
+
return Qnil;
}
@@ -2394,9 +2397,9 @@ static VALUE
zip_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, memoval))
{
struct MEMO *memo = (struct MEMO *)memoval;
- volatile VALUE result = memo->v1;
- volatile VALUE args = memo->v2;
- volatile VALUE tmp;
+ VALUE result = memo->v1;
+ VALUE args = memo->v2;
+ VALUE tmp;
int i;
tmp = rb_ary_new2(RARRAY_LEN(args) + 1);
@@ -2423,6 +2426,9 @@ zip_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, memoval))
else {
rb_ary_push(result, tmp);
}
+
+ RB_GC_GUARD(args);
+
return Qnil;
}
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-06-23 3:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-23 3:02 [PATCH] enum.c: remove volatile, use RB_GC_GUARD Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).