From 93f6b2a36ed097cf615606bcc30f69a13c0bc8e6 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 1 Apr 2015 02:09:18 +0000 Subject: [PATCH] dir.c: reduce indirect arguments * dir.c (push_glob): remove indirect links of arguments for trampoline. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ dir.c | 27 +++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 790673b7c1..9fb54bb8c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Apr 1 11:09:15 2015 Nobuyoshi Nakada + + * dir.c (push_glob): remove indirect links of arguments for + trampoline. + Wed Apr 1 09:59:12 2015 Nobuyoshi Nakada * lib/fileutils.rb (FileUtils#mv): show the exact target path in diff --git a/dir.c b/dir.c index ab36950ffd..4b83563717 100644 --- a/dir.c +++ b/dir.c @@ -2060,10 +2060,23 @@ ruby_brace_glob_with_enc(const char *str, int flags, ruby_glob_func *func, VALUE return ruby_brace_glob0(str, flags & ~GLOB_VERBOSE, func, arg, enc); } +struct push_glob_args { + struct glob_args glob; + int flags; +}; + +static int +push_caller(const char *path, VALUE val, void *enc) +{ + struct push_glob_args *arg = (struct push_glob_args *)val; + + return ruby_glob0(path, arg->flags, rb_glob_caller, (VALUE)&arg->glob, enc); +} + static int push_glob(VALUE ary, VALUE str, int flags) { - struct glob_args args; + struct push_glob_args args; rb_encoding *enc = rb_enc_get(str); #ifdef __APPLE__ @@ -2071,16 +2084,18 @@ push_glob(VALUE ary, VALUE str, int flags) #endif if (enc == rb_usascii_encoding()) enc = rb_filesystem_encoding(); if (enc == rb_usascii_encoding()) enc = rb_ascii8bit_encoding(); - args.func = push_pattern; - args.value = ary; - args.enc = enc; + flags |= GLOB_VERBOSE; + args.glob.func = push_pattern; + args.glob.value = ary; + args.glob.enc = enc; + args.flags = flags; #ifdef __APPLE__ enc = rb_utf8_encoding(); #endif RB_GC_GUARD(str); - return ruby_brace_glob0(RSTRING_PTR(str), flags | GLOB_VERBOSE, - rb_glob_caller, (VALUE)&args, enc); + return ruby_brace_expand(RSTRING_PTR(str), flags, + push_caller, (VALUE)&args, enc); } static VALUE