faster_path 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -4
- data/lib/faster_path/version.rb +1 -1
- data/src/basename.rs +10 -26
- data/src/basename_for_chop.rs +12 -2
- data/src/dirname_for_chop.rs +12 -7
- data/src/lib.rs +1 -1
- 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: 175d2f5deb162ae5b91fd8c6a78f3a4ec9f2c614
|
4
|
+
data.tar.gz: 85f78d5451c0e8b34bc00d282e08e6c7d84715ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62cdddd68edc6109686eda078a585038d8d3c1737330d025b0cf9b863f39696e4074a916c82ac331a7801e62a01a9138ff84d2c0c4e5e1ac4ad93a157dce548e
|
7
|
+
data.tar.gz: a66eb90ede0d919ba85c04714f2fa3412d7b8f6e099e933a50210c6f81f8a1cc94ede8805c498c5ba80ec1b2c56c9be1acdbe7cb8d4df34119ca0aa00d6b6eb5
|
data/README.md
CHANGED
@@ -3,9 +3,7 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/danielpclark/faster_path.svg?branch=master)](https://travis-ci.org/danielpclark/faster_path)
|
4
4
|
[![Tweet This](https://raw.githubusercontent.com/danielpclark/faster_path/master/assets/tweet.png)](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.)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
#### As of gem version 0.0.9 this shaves off 66% of my Rails applications page load time.
|
6
|
+
#### This gem shaves off more than 30% of my Rails application page load time.
|
9
7
|
|
10
8
|
The primary **GOAL** of this project is to improve performance in the most heavily used areas of Ruby as
|
11
9
|
path relation and file lookup is currently a huge bottleneck in performance. As this is the case the
|
@@ -88,7 +86,7 @@ Current methods implemented:
|
|
88
86
|
|---|---|:---:|
|
89
87
|
| `FasterPath.absolute?` | `Pathname#absolute?` | 1234.6% |
|
90
88
|
| `FasterPath.basename` | `File.basename` | 31.3% |
|
91
|
-
| `FasterPath.chop_basename` | `Pathname#chop_basename` |
|
89
|
+
| `FasterPath.chop_basename` | `Pathname#chop_basename` | 66.0% |
|
92
90
|
| `FasterPath.relative?` | `Pathname#relative?` | 1262.3% |
|
93
91
|
| `FasterPath.blank?` | | |
|
94
92
|
|
data/lib/faster_path/version.rb
CHANGED
data/src/basename.rs
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
#[allow(dead_code)]
|
2
2
|
fn rubyish_basename(string: &str, globish_string: &str) -> String {
|
3
|
-
let result = if globish_string
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
first
|
9
|
-
} else {
|
10
|
-
if &string[string.len()-globish_string.len()..] == globish_string {
|
11
|
-
&string[0..string.len()-globish_string.len()]
|
12
|
-
} else {
|
13
|
-
string
|
14
|
-
}.rsplit_terminator(MAIN_SEPARATOR).nth(0).unwrap_or("")
|
15
|
-
}
|
3
|
+
let result = if globish_string == ".*" {
|
4
|
+
let base = string.rsplit_terminator(MAIN_SEPARATOR).nth(0).unwrap_or("");
|
5
|
+
let index = base.rfind(".");
|
6
|
+
let (first, _) = base.split_at(index.unwrap());
|
7
|
+
first
|
16
8
|
} else {
|
17
9
|
if &string[string.len()-globish_string.len()..] == globish_string {
|
18
10
|
&string[0..string.len()-globish_string.len()]
|
@@ -69,19 +61,11 @@ pub extern fn basename(str_pth: *const c_char, comp_ext: *const c_char) -> *cons
|
|
69
61
|
let string = str::from_utf8(c_str1.to_bytes()).unwrap();
|
70
62
|
let globish_string = str::from_utf8(c_str2.to_bytes()).unwrap();
|
71
63
|
|
72
|
-
let result = if globish_string
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
first
|
78
|
-
} else {
|
79
|
-
if &string[string.len()-globish_string.len()..] == globish_string {
|
80
|
-
&string[0..string.len()-globish_string.len()]
|
81
|
-
} else {
|
82
|
-
string
|
83
|
-
}.rsplit_terminator(MAIN_SEPARATOR).nth(0).unwrap_or("")
|
84
|
-
}
|
64
|
+
let result = if globish_string == ".*" {
|
65
|
+
let base = string.rsplit_terminator(MAIN_SEPARATOR).nth(0).unwrap_or("");
|
66
|
+
let index = base.rfind(".");
|
67
|
+
let (first, _) = base.split_at(index.unwrap());
|
68
|
+
first
|
85
69
|
} else {
|
86
70
|
if &string[string.len()-globish_string.len()..] == globish_string {
|
87
71
|
&string[0..string.len()-globish_string.len()]
|
data/src/basename_for_chop.rs
CHANGED
@@ -8,8 +8,18 @@ pub extern fn basename_for_chop(string: *const c_char) -> *const c_char {
|
|
8
8
|
|
9
9
|
let r_str = str::from_utf8(c_str.to_bytes()).unwrap();
|
10
10
|
|
11
|
-
let
|
11
|
+
let mut offset = 0;
|
12
|
+
let mut trailing_slashes = r_str.chars().rev();
|
13
|
+
loop {
|
14
|
+
match trailing_slashes.next() {
|
15
|
+
Some(MAIN_SEPARATOR) => { offset = offset + 1 },
|
16
|
+
_ => { break },
|
17
|
+
}
|
18
|
+
}
|
12
19
|
|
13
|
-
let
|
20
|
+
let r_str = &r_str[0..r_str.len()-offset];
|
21
|
+
let part = r_str.rsplit_terminator(MAIN_SEPARATOR).nth(0).unwrap_or("");
|
22
|
+
|
23
|
+
let output = CString::new(part).unwrap();
|
14
24
|
output.into_raw()
|
15
25
|
}
|
data/src/dirname_for_chop.rs
CHANGED
@@ -12,14 +12,19 @@ pub extern fn dirname_for_chop(string: *const c_char) -> *const c_char {
|
|
12
12
|
return string
|
13
13
|
}
|
14
14
|
|
15
|
-
let
|
15
|
+
let mut offset = 0;
|
16
|
+
let mut trailing_slashes = r_str.chars().rev();
|
17
|
+
loop {
|
18
|
+
match trailing_slashes.next() {
|
19
|
+
Some(MAIN_SEPARATOR) => { offset = offset + 1 },
|
20
|
+
_ => { break },
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
let r_str = &r_str[0..r_str.len()-offset];
|
16
25
|
|
17
|
-
let
|
18
|
-
format!("{}{}", path.to_str().unwrap(), MAIN_SEPARATOR)
|
19
|
-
} else {
|
20
|
-
format!("{}", path.to_str().unwrap())
|
21
|
-
};
|
26
|
+
let base = r_str.rsplit_terminator(MAIN_SEPARATOR).nth(0).unwrap_or("");
|
22
27
|
|
23
|
-
let output = CString::new(
|
28
|
+
let output = CString::new(&r_str[0..r_str.len()-base.len()]).unwrap();
|
24
29
|
output.into_raw()
|
25
30
|
}
|
data/src/lib.rs
CHANGED
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.1.
|
4
|
+
version: 0.1.4
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|