dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 1/2] enum.c: remove volatile, use RB_GC_GUARD
Date: Wed, 24 Jun 2015 03:37:01 +0000	[thread overview]
Message-ID: <1435117022-30592-1-git-send-email-e@80x24.org> (raw)

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


             reply	other threads:[~2015-06-24  3:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-24  3:37 Eric Wong [this message]
2015-06-24  3:37 ` [PATCH 2/2] enum.c (enum_minmax): simplify return value creation Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435117022-30592-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).