faster_path 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/faster_path.gemspec +1 -1
- data/lib/faster_path.rb +5 -0
- data/lib/faster_path/optional/monkeypatches.rb +4 -0
- data/lib/faster_path/optional/refinements.rb +4 -0
- data/lib/faster_path/version.rb +1 -1
- data/src/lib.rs +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 145d0ead52899b0287c3854351371ed572753abf
|
4
|
+
data.tar.gz: 26a96e5e5120c5697f44d1dd2aae6d0780f361c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d05a6334782f4994a0ff6d25f4b9e3851c08fc26dec8e32e8533ea459f602fe9df0ec2ac8a8d557ad4d278b713d7073db0ec641754f0537416e9bfa1ee3decf6
|
7
|
+
data.tar.gz: 98e70ecc789fbdb19d945f07a0f3c2ab2844c719ef7d41794aace5e659a3b9fa0353d4ca409bea0a28f1549d0db698f494a1d819d7de2cf2158a5fa6def61dd9
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# FasterPath
|
2
2
|
[](https://badge.fury.io/rb/faster_path)
|
3
3
|
[](https://travis-ci.org/danielpclark/faster_path)
|
4
|
+
[](https://twitter.com/share?url=https%3A%2F%2Fgithub.com%2Fdanielpclark%2Ffaster_path&via=6ftdan&hashtags=Ruby&text=You%20could%20save%2015%25%20or%20more%20on%20website%20load%20time%20by%20switching%20to%20the%20FasterPath%20gem.)
|
4
5
|
|
5
6
|
The primary **GOAL** of this project is to improve performance in the most heavily used areas of Ruby as
|
6
7
|
path relation and file lookup is currently a huge bottleneck in performance. As this is the case the
|
@@ -86,6 +87,7 @@ Current methods implemented:
|
|
86
87
|
|---|---|:---:|
|
87
88
|
| `FasterPath.absolute?` | `Pathname#absolute?` | 1234.6% |
|
88
89
|
| `FasterPath.chop_basename` | `Pathname#chop_basename` | 27.5% |
|
90
|
+
| `FasterPath.relative?` | `Pathname#relative?` | 1262.3% |
|
89
91
|
| `FasterPath.blank?` | | |
|
90
92
|
|
91
93
|
You may choose to use the methods directly, or scope change to rewrite behavior on the
|
@@ -109,11 +111,19 @@ require "faster_path/optional/monkeypatches"
|
|
109
111
|
FasterPath.sledgehammer_everything!
|
110
112
|
```
|
111
113
|
|
112
|
-
## Development
|
114
|
+
## Getting Started with Development
|
113
115
|
|
114
|
-
|
116
|
+
The primary methods to target are mostly listed in the **Why** section above. You may find the Ruby
|
117
|
+
source code useful for Pathname's [Ruby source](https://github.com/ruby/ruby/blob/32674b167bddc0d737c38f84722986b0f228b44b/ext/pathname/lib/pathname.rb),
|
118
|
+
[C source](https://github.com/ruby/ruby/blob/32674b167bddc0d737c38f84722986b0f228b44b/ext/pathname/pathname.c), and
|
119
|
+
[tests](https://github.com/ruby/ruby/blob/32674b167bddc0d737c38f84722986b0f228b44b/test/pathname/test_pathname.rb).
|
115
120
|
|
116
|
-
|
121
|
+
Methods will be written as exclusively in Rust as possible. Even just writing a **not** in Ruby with a
|
122
|
+
Rust method like `!absolute?` _(not absolute)_ drops 39% of the performance already gained in Rust.
|
123
|
+
Whenever feasible implement it in Rust.
|
124
|
+
|
125
|
+
After checking out the repo, make sure you have Rust installed. Then run `bundle && rake build_lib` .
|
126
|
+
Then, run `rake test` to run the tests, and `rake bench` for benchmarks.
|
117
127
|
|
118
128
|
## Contributing
|
119
129
|
|
data/faster_path.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/danielpclark/faster_path"
|
14
14
|
spec.license = "MIT OR Apache-2.0"
|
15
15
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|assets)/}) }
|
17
17
|
spec.bindir = "exe"
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.extensions << "ext/faster_path/extconf.rb"
|
data/lib/faster_path.rb
CHANGED
@@ -8,6 +8,10 @@ module FasterPath
|
|
8
8
|
Rust.is_absolute(pth)
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.relative?(pth)
|
12
|
+
Rust.is_relative(pth)
|
13
|
+
end
|
14
|
+
|
11
15
|
# Spec to Pathname#chop_basename
|
12
16
|
# WARNING! Pathname#chop_basename in STDLIB doesn't handle blank strings correctly!
|
13
17
|
# This implementation correctly handles blank strings just as Pathname had intended
|
@@ -33,6 +37,7 @@ module FasterPath
|
|
33
37
|
"#{File.expand_path("../target/release/", File.dirname(__FILE__))}/#{prefix}faster_path.#{FFI::Platform::LIBSUFFIX}"
|
34
38
|
end
|
35
39
|
attach_function :is_absolute, [ :string ], :bool
|
40
|
+
attach_function :is_relative, [ :string ], :bool
|
36
41
|
attach_function :is_blank, [ :string ], :bool
|
37
42
|
attach_function :basename, [ :string ], :string
|
38
43
|
attach_function :dirname, [ :string ], :string
|
data/lib/faster_path/version.rb
CHANGED
data/src/lib.rs
CHANGED
@@ -24,6 +24,19 @@ pub extern fn is_absolute(string: *const c_char) -> bool {
|
|
24
24
|
r_str.chars().next().unwrap_or("muffins".chars().next().unwrap()) == MAIN_SEPARATOR
|
25
25
|
}
|
26
26
|
|
27
|
+
#[no_mangle]
|
28
|
+
pub extern fn is_relative(string: *const c_char) -> bool {
|
29
|
+
let c_str = unsafe {
|
30
|
+
assert!(!string.is_null());
|
31
|
+
|
32
|
+
CStr::from_ptr(string)
|
33
|
+
};
|
34
|
+
|
35
|
+
let r_str = str::from_utf8(c_str.to_bytes()).unwrap_or("");
|
36
|
+
|
37
|
+
r_str.chars().next().unwrap_or("muffins".chars().next().unwrap()) != MAIN_SEPARATOR
|
38
|
+
}
|
39
|
+
|
27
40
|
#[no_mangle]
|
28
41
|
pub extern fn is_blank(string: *const c_char) -> bool {
|
29
42
|
let c_str = unsafe {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faster_path
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|