summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 15:52:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 15:52:40 +0000
commit46df9c425ea0ef8d8162af06d02de3506e0240b5 (patch)
tree664c5e2b513f678b455c3cbef3575fa9423542c8
parentddba2014c642b886fc9ae3bf44d6a8a10af58be5 (diff)
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
-rw-r--r--ChangeLog6
-rw-r--r--file.c10
2 files changed, 12 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 438b686df9e..64de792d034 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Dec 9 00:52:37 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@atdot.net>
* compile.c (iseq_ibf_dump): dump extra data just string length.
diff --git a/file.c b/file.c
index 9259c1c3006..824fc800ab1 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;