ruby-changes:40891
From: nobu <ko1@a...>
Date: Wed, 9 Dec 2015 00:53:34 +0900 (JST)
Subject: [ruby-changes:40891] nobu:r52970 (trunk): file.c: call get_stat only once
nobu 2015-12-09 00:52:40 +0900 (Wed, 09 Dec 2015) New Revision: 52970 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52970 Log: file.c: call get_stat only once * file.c (rb_stat_wr, rb_stat_ww): call get_stat only once and reduce checking struct. patch by Yuki Kurihara in [ruby-core:71949]. [Misc #11789] Modified files: trunk/ChangeLog trunk/file.c Index: ChangeLog =================================================================== --- ChangeLog (revision 52969) +++ ChangeLog (revision 52970) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Dec 9 00:52:37 2015 Nobuyoshi Nakada <nobu@r...> + + * file.c (rb_stat_wr, rb_stat_ww): call get_stat only once and + reduce checking struct. patch by Yuki Kurihara in + [ruby-core:71949]. [Misc #11789] + Wed Dec 9 00:24:33 2015 Koichi Sasada <ko1@a...> * compile.c (iseq_ibf_dump): dump extra data just string length. Index: file.c =================================================================== --- file.c (revision 52969) +++ file.c (revision 52970) @@ -5184,8 +5184,9 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/file.c#L5184 rb_stat_wr(VALUE obj) { #ifdef S_IROTH - if ((get_stat(obj)->st_mode & (S_IROTH)) == S_IROTH) { - return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); + struct stat *st = get_stat(obj); + if ((st->st_mode & (S_IROTH)) == S_IROTH) { + return UINT2NUM(st->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); } else { return Qnil; @@ -5276,8 +5277,9 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/file.c#L5277 rb_stat_ww(VALUE obj) { #ifdef S_IROTH - if ((get_stat(obj)->st_mode & (S_IWOTH)) == S_IWOTH) { - return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); + struct stat *st = get_stat(obj); + if ((st->st_mode & (S_IWOTH)) == S_IWOTH) { + return UINT2NUM(st->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); } else { return Qnil; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/