File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
lib/action_dispatch/routing Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change
1
+ * Speed up ` ActionDispatch::Routing::Mapper::Scope#[] ` by merging frame hashes.
2
+
3
+ * Gannon McGibbon*
4
+
1
5
* Allow bots to ignore ` allow_browser ` .
2
6
3
7
* Matthew Nguyen*
Original file line number Diff line number Diff line change @@ -2293,9 +2293,9 @@ class Scope # :nodoc:
2293
2293
2294
2294
attr_reader :parent , :scope_level
2295
2295
2296
- def initialize ( hash , parent = NULL , scope_level = nil )
2297
- @hash = hash
2296
+ def initialize ( hash , parent = ROOT , scope_level = nil )
2298
2297
@parent = parent
2298
+ @hash = parent ? parent . frame . merge ( hash ) : hash
2299
2299
@scope_level = scope_level
2300
2300
end
2301
2301
@@ -2308,7 +2308,7 @@ def null?
2308
2308
end
2309
2309
2310
2310
def root?
2311
- @parent . null?
2311
+ @parent == ROOT
2312
2312
end
2313
2313
2314
2314
def resources?
@@ -2353,23 +2353,22 @@ def new_level(level)
2353
2353
end
2354
2354
2355
2355
def []( key )
2356
- scope = find { |node | node . frame . key? key }
2357
- scope && scope . frame [ key ]
2356
+ frame [ key ]
2358
2357
end
2359
2358
2359
+ def frame ; @hash ; end
2360
+
2360
2361
include Enumerable
2361
2362
2362
2363
def each
2363
2364
node = self
2364
- until node . equal? NULL
2365
+ until node . equal? ROOT
2365
2366
yield node
2366
2367
node = node . parent
2367
2368
end
2368
2369
end
2369
2370
2370
- def frame ; @hash ; end
2371
-
2372
- NULL = Scope . new ( nil , nil )
2371
+ ROOT = Scope . new ( { } , nil )
2373
2372
end
2374
2373
2375
2374
def initialize ( set ) # :nodoc:
You can’t perform that action at this time.
0 commit comments