Get rid of the redundant stat() in rb_check_realpath_internal
This commit is contained in:
parent
167d139487
commit
2c6512fe67
Notes:
git
2020-07-07 00:27:12 +09:00
4
file.c
4
file.c
@ -4389,7 +4389,6 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum
|
|||||||
VALUE unresolved_path;
|
VALUE unresolved_path;
|
||||||
char *resolved_ptr = NULL;
|
char *resolved_ptr = NULL;
|
||||||
VALUE resolved;
|
VALUE resolved;
|
||||||
struct stat st;
|
|
||||||
|
|
||||||
if (mode == RB_REALPATH_DIR) {
|
if (mode == RB_REALPATH_DIR) {
|
||||||
return rb_check_realpath_emulate(basedir, path, origenc, mode);
|
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());
|
resolved = ospath_new(resolved_ptr, strlen(resolved_ptr), rb_filesystem_encoding());
|
||||||
free(resolved_ptr);
|
free(resolved_ptr);
|
||||||
|
|
||||||
|
# if !defined(__LINUX__) && !defined(__APPLE__)
|
||||||
/* As `resolved` is a String in the filesystem encoding, no
|
/* As `resolved` is a String in the filesystem encoding, no
|
||||||
* conversion is needed */
|
* conversion is needed */
|
||||||
|
struct stat st;
|
||||||
if (stat_without_gvl(RSTRING_PTR(resolved), &st) < 0) {
|
if (stat_without_gvl(RSTRING_PTR(resolved), &st) < 0) {
|
||||||
if (mode == RB_REALPATH_CHECK) {
|
if (mode == RB_REALPATH_CHECK) {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
rb_sys_fail_path(unresolved_path);
|
rb_sys_fail_path(unresolved_path);
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
if (origenc && origenc != rb_enc_get(resolved)) {
|
if (origenc && origenc != rb_enc_get(resolved)) {
|
||||||
if (!rb_enc_str_asciionly_p(resolved)) {
|
if (!rb_enc_str_asciionly_p(resolved)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user