ruby-changes:62148
From: Jean <ko1@a...>
Date: Tue, 7 Jul 2020 00:26:56 +0900 (JST)
Subject: [ruby-changes:62148] 2c6512fe67 (master): Get rid of the redundant stat() in rb_check_realpath_internal
https://git.ruby-lang.org/ruby.git/commit/?id=2c6512fe67 From 2c6512fe67a275ce4d251f3c5d304bc523597f42 Mon Sep 17 00:00:00 2001 From: Jean Boussier <jean.boussier@g...> Date: Sat, 27 Jun 2020 23:10:42 +0200 Subject: Get rid of the redundant stat() in rb_check_realpath_internal diff --git a/file.c b/file.c index f9237b0..d9b113e 100644 --- a/file.c +++ b/file.c @@ -4389,7 +4389,6 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum https://github.com/ruby/ruby/blob/trunk/file.c#L4389 VALUE unresolved_path; char *resolved_ptr = NULL; VALUE resolved; - struct stat st; if (mode == RB_REALPATH_DIR) { return rb_check_realpath_emulate(basedir, path, origenc, mode); @@ -4420,14 +4419,17 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum https://github.com/ruby/ruby/blob/trunk/file.c#L4419 resolved = ospath_new(resolved_ptr, strlen(resolved_ptr), rb_filesystem_encoding()); free(resolved_ptr); +# if !defined(__LINUX__) && !defined(__APPLE__) /* As `resolved` is a String in the filesystem encoding, no * conversion is needed */ + struct stat st; if (stat_without_gvl(RSTRING_PTR(resolved), &st) < 0) { if (mode == RB_REALPATH_CHECK) { return Qnil; } rb_sys_fail_path(unresolved_path); } +# endif if (origenc && origenc != rb_enc_get(resolved)) { if (!rb_enc_str_asciionly_p(resolved)) { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/