aboutsummaryrefslogtreecommitdiffstats
path: root/dir.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-23 00:49:26 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-23 00:49:26 +0000
commit5bbca2bdde5dad0e4e565db37aa89c877c75edc8 (patch)
tree822306417b67e66aa27d1e2efacb600fcd0fcb6c /dir.c
parentebcf79d988f7504c580f0b12f3d026115956be4f (diff)
downloadruby-5bbca2bdde5dad0e4e565db37aa89c877c75edc8.tar.gz
dir.c (check_dirname): avoid volatile, use return value
volatile is unnecessary since we use rb_sys_fail_path nowadays and that prevents the path argument from being GC-ed. Using a return value instead of modifying the argument directly simplifies the generated code (on 32-bit x86): text data bss dec hex filename 20744 40 20 20804 5144 dir.o-orig 20720 40 20 20780 512c dir.o * dir.c (check_dirname): avoid volatile, use return value (dir_s_chroot, dir_s_mkdir, dir_s_rmdir): adjust callers git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/dir.c b/dir.c
index 311a5e0336..e271503dce 100644
--- a/dir.c
+++ b/dir.c
@@ -1004,10 +1004,10 @@ dir_s_getwd(VALUE dir)
return rb_dir_getwd();
}
-static void
-check_dirname(volatile VALUE *dir)
+static VALUE
+check_dirname(VALUE dir)
{
- VALUE d = *dir;
+ VALUE d = dir;
char *path, *pend;
long len;
rb_encoding *enc;
@@ -1020,7 +1020,7 @@ check_dirname(volatile VALUE *dir)
if (pend - path < len) {
d = rb_str_subseq(d, 0, pend - path);
}
- *dir = rb_str_encode_ospath(d);
+ return rb_str_encode_ospath(d);
}
#if defined(HAVE_CHROOT)
@@ -1036,7 +1036,7 @@ check_dirname(volatile VALUE *dir)
static VALUE
dir_s_chroot(VALUE dir, VALUE path)
{
- check_dirname(&path);
+ path = check_dirname(path);
if (chroot(RSTRING_PTR(path)) == -1)
rb_sys_fail_path(path);
@@ -1074,7 +1074,7 @@ dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
mode = 0777;
}
- check_dirname(&path);
+ path = check_dirname(path);
if (mkdir(RSTRING_PTR(path), mode) == -1)
rb_sys_fail_path(path);
@@ -1093,7 +1093,7 @@ dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
static VALUE
dir_s_rmdir(VALUE obj, VALUE dir)
{
- check_dirname(&dir);
+ dir = check_dirname(dir);
if (rmdir(RSTRING_PTR(dir)) < 0)
rb_sys_fail_path(dir);