Project

General

Profile

Actions

Feature #22060

open

Improve Pathname by migrating internal methods to pathname.c

Feature #22060: Improve Pathname by migrating internal methods to pathname.c

Added by nobu (Nobuyoshi Nakada) 6 days ago. Updated 4 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:125441]

Description

Currently, Pathname implementation is mainly in pathname_builtin.rb and only a few methods in pathname.c.
The code in pathname_builtin.rb is using File methods probably for platform portabilities.
This is kind of smart but is a roundabout way and is hard to understand.
I think it can be easier to understand and more efficient by migrating some internal methods to pathname.c.

Comparison with master 9fefb48643:

master w/o JIT PR w/o JIT master w/ JIT PR w/ JIT
p1+p2 332.541k 696.202k 347.315k 952.254k
- 2.09x 1.04x 2.86x
abs.root? 3.282M 97.180M 3.504M 82.821M
- 29.61x 1.07x 25.23x
rel.root? 3.298M 101.917M 3.535M 96.676M
- 30.91x 1.07x 29.32x
abs.absolute? 22.184M 110.749M 31.099M 129.464M
- 4.99x 1.40x 5.84x
rel.absolute? 30.862M 111.914M 47.010M 118.712M
- 3.63x 1.52x 3.85x
p1.cleanpath 395.604k 904.909k 418.752k 1.342M
- 2.29x 1.06x 3.39x
p2.cleanpath 445.949k 982.354k 468.972k 1.451M
- 2.20x 1.05x 3.25x
relative_path_from 137.595k 271.209k 144.976k 393.710k
- 1.97x 1.05x 2.86x

Although YJIT is not effective on Pathname#root?, probably it is too simple for JIT.

GH-16907

Updated by nobu (Nobuyoshi Nakada) 4 days ago Actions #1 [ruby-core:125450]

On Windows, Pathname("a:.").absolute? returns true, while File.absolute_path?("a:.") returns false.
This path is typically a relative path based on the current directory on the drive, so I don't think it would be considered an absolute path.
What is the reason for this behavior?

Updated by nobu (Nobuyoshi Nakada) 4 days ago Actions #2

  • Description updated (diff)
Actions

Also available in: PDF Atom