roda 3.46.0 → 3.47.0
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/CHANGELOG +4 -0
- data/doc/release_notes/3.47.0.txt +13 -0
- data/lib/roda.rb +1 -1
- data/lib/roda/plugins/_optimized_matching.rb +46 -6
- data/lib/roda/plugins/mail_processor.rb +1 -1
- data/lib/roda/plugins/type_routing.rb +1 -1
- data/lib/roda/request.rb +1 -1
- data/lib/roda/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cad702e3b962a1e1b64e631ef77ea1ccca4eb1c630f1ac2e73b5c169b505744
|
4
|
+
data.tar.gz: f6576f0bd8b1a921435121ce9043a04f04f5560eca7a2eb93f5f39500a62dc1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7def8965cb5ce9b12c96d16f2edb4e4428b41367b91ebfb20132332b87b04fceba29fdb537ea91c25eda7cc72d07ba3d329d12c073746309b125275d8cc616ad
|
7
|
+
data.tar.gz: 7acab06b22c80a697e4e250b857544aa337fcdf9a1c2065adae61cac4d1d17171ea374300104855e192fc4700d39d5c8fb9ebe7e8ee2ebc5d00fd6776c7a9f64
|
data/CHANGELOG
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
= Improvements
|
2
|
+
|
3
|
+
* The r.on optimization added in 3.46.0 has been extended to optimize
|
4
|
+
all single argument calls. This results in the following speedups
|
5
|
+
based on argument type:
|
6
|
+
|
7
|
+
* Hash matching: 10%
|
8
|
+
* Array/Symbol/Class matching: 15%
|
9
|
+
* Proc matching: 25%
|
10
|
+
* true matching: 45%
|
11
|
+
* false/nil matching: 65%
|
12
|
+
|
13
|
+
* Other minor performance improvements have been made.
|
data/lib/roda.rb
CHANGED
@@ -213,7 +213,7 @@ class Roda
|
|
213
213
|
plugin :direct_call
|
214
214
|
end
|
215
215
|
|
216
|
-
if ([:on, :is, :_verb, :_match_class_String, :_match_class_Integer, :_match_string, :_match_regexp, :empty_path
|
216
|
+
if ([:on, :is, :_verb, :_match_class_String, :_match_class_Integer, :_match_string, :_match_regexp, :empty_path?, :if_match, :match, :_match_class]).all?{|m| self::RodaRequest.instance_method(m).owner == RequestMethods}
|
217
217
|
plugin :_optimized_matching
|
218
218
|
end
|
219
219
|
end
|
@@ -52,20 +52,60 @@ class Roda
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
elsif matcher == Integer
|
55
|
-
if matchdata =
|
55
|
+
if matchdata = /\A\/(\d+)(?=\/|\z)/.match(@remaining_path)
|
56
56
|
@remaining_path = matchdata.post_match
|
57
57
|
always{yield(matchdata[1].to_i)}
|
58
58
|
end
|
59
59
|
else
|
60
|
-
|
60
|
+
path = @remaining_path
|
61
|
+
captures = @captures.clear
|
62
|
+
meth = :"_match_class_#{matcher}"
|
63
|
+
if respond_to?(meth, true)
|
64
|
+
# Allow calling private methods, as match methods are generally private
|
65
|
+
if send(meth, &block)
|
66
|
+
block_result(yield(*captures))
|
67
|
+
throw :halt, response.finish
|
68
|
+
else
|
69
|
+
@remaining_path = path
|
70
|
+
false
|
71
|
+
end
|
72
|
+
else
|
73
|
+
unsupported_matcher(matcher)
|
74
|
+
end
|
61
75
|
end
|
62
76
|
when Regexp
|
63
|
-
if matchdata =
|
77
|
+
if matchdata = self.class.cached_matcher(matcher){matcher}.match(@remaining_path)
|
64
78
|
@remaining_path = matchdata.post_match
|
65
79
|
always{yield(*matchdata.captures)}
|
66
80
|
end
|
81
|
+
when true
|
82
|
+
always(&block)
|
83
|
+
when false, nil
|
84
|
+
# nothing
|
67
85
|
else
|
68
|
-
|
86
|
+
path = @remaining_path
|
87
|
+
captures = @captures.clear
|
88
|
+
|
89
|
+
matched = case matcher
|
90
|
+
when Array
|
91
|
+
_match_array(matcher)
|
92
|
+
when Hash
|
93
|
+
_match_hash(matcher)
|
94
|
+
when Symbol
|
95
|
+
_match_symbol(matcher)
|
96
|
+
when Proc
|
97
|
+
matcher.call
|
98
|
+
else
|
99
|
+
unsupported_matcher(matcher)
|
100
|
+
end
|
101
|
+
|
102
|
+
if matched
|
103
|
+
block_result(yield(*captures))
|
104
|
+
throw :halt, response.finish
|
105
|
+
else
|
106
|
+
@remaining_path = path
|
107
|
+
false
|
108
|
+
end
|
69
109
|
end
|
70
110
|
when 0
|
71
111
|
always(&block)
|
@@ -111,7 +151,7 @@ class Roda
|
|
111
151
|
always{yield rp[1, len]}
|
112
152
|
end
|
113
153
|
elsif matcher == Integer
|
114
|
-
if matchdata =
|
154
|
+
if matchdata = /\A\/(\d+)\z/.match(@remaining_path)
|
115
155
|
@remaining_path = ''
|
116
156
|
always{yield(matchdata[1].to_i)}
|
117
157
|
end
|
@@ -119,7 +159,7 @@ class Roda
|
|
119
159
|
if_match(args << TERM, &block)
|
120
160
|
end
|
121
161
|
when Regexp
|
122
|
-
if (matchdata =
|
162
|
+
if (matchdata = self.class.cached_matcher(matcher){matcher}.match(@remaining_path)) && matchdata.post_match.empty?
|
123
163
|
@remaining_path = ''
|
124
164
|
always{yield(*matchdata.captures)}
|
125
165
|
end
|
data/lib/roda/request.rb
CHANGED
@@ -517,7 +517,7 @@ class Roda
|
|
517
517
|
# SCRIPT_NAME to include the matched path, removes the matched
|
518
518
|
# path from PATH_INFO, and updates captures with any regex captures.
|
519
519
|
def consume(pattern)
|
520
|
-
if matchdata =
|
520
|
+
if matchdata = pattern.match(@remaining_path)
|
521
521
|
@remaining_path = matchdata.post_match
|
522
522
|
captures = matchdata.captures
|
523
523
|
captures = yield(*captures) if block_given?
|
data/lib/roda/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.47.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -217,6 +217,7 @@ extra_rdoc_files:
|
|
217
217
|
- doc/release_notes/3.44.0.txt
|
218
218
|
- doc/release_notes/3.45.0.txt
|
219
219
|
- doc/release_notes/3.46.0.txt
|
220
|
+
- doc/release_notes/3.47.0.txt
|
220
221
|
- doc/release_notes/3.5.0.txt
|
221
222
|
- doc/release_notes/3.6.0.txt
|
222
223
|
- doc/release_notes/3.7.0.txt
|
@@ -270,6 +271,7 @@ files:
|
|
270
271
|
- doc/release_notes/3.44.0.txt
|
271
272
|
- doc/release_notes/3.45.0.txt
|
272
273
|
- doc/release_notes/3.46.0.txt
|
274
|
+
- doc/release_notes/3.47.0.txt
|
273
275
|
- doc/release_notes/3.5.0.txt
|
274
276
|
- doc/release_notes/3.6.0.txt
|
275
277
|
- doc/release_notes/3.7.0.txt
|