From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.5 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: spew@80x24.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 4A1EF20338 for ; Tue, 23 Jun 2015 03:02:27 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] enum.c: remove volatile, use RB_GC_GUARD Date: Tue, 23 Jun 2015 03:02:26 +0000 Message-Id: <1435028546-30335-1-git-send-email-e@80x24.org> List-Id: 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