From 95ac88131bead1d375a1d5555b388fa863a735c8 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 8 Dec 2015 15:52:40 +0000 Subject: 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- file.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index 9259c1c300..824fc800ab 100644 --- a/file.c +++ b/file.c @@ -5184,8 +5184,9 @@ static VALUE 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 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; -- cgit v1.2.3