Decrease route_set allocations
In handle_positional_args `Array#-=` is used which allocates a new array. Instead we can iterate through and delete elements, modifying the array in place. Also `Array#take` allocates a new array. We can build the same by iterating over the other element. This change buys us 106,470 bytes of memory and 2,663 fewer objects per request.
This commit is contained in:
parent
097ec6fb7c
commit
0cbec58ae4
@ -267,9 +267,13 @@ def handle_positional_args(controller_options, inner_options, args, result, path
|
||||
path_params -= controller_options.keys
|
||||
path_params -= result.keys
|
||||
end
|
||||
path_params -= inner_options.keys
|
||||
path_params.take(args.size).each do |param|
|
||||
result[param] = args.shift
|
||||
inner_options.each do |key, _|
|
||||
path_params.delete(key)
|
||||
end
|
||||
|
||||
args.each_with_index do |arg, index|
|
||||
param = path_params[index]
|
||||
result[param] = arg if param
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user