summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2020-06-27 23:10:42 +0200
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-07-07 00:26:37 +0900
commit2c6512fe67a275ce4d251f3c5d304bc523597f42 (patch)
tree8472f30824f4cc700f0d9cefcc175b6c91d0058b /file.c
parent167d139487d67613bd02522e24476f06ffa137b7 (diff)
Get rid of the redundant stat() in rb_check_realpath_internal
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3267
Diffstat (limited to 'file.c')
-rw-r--r--file.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/file.c b/file.c
index f9237b042ad..d9b113ef89f 100644
--- a/file.c
+++ b/file.c
@@ -4389,7 +4389,6 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum
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
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)) {