From 4c423e967f5a53e70c1e3c46a69c861a7b870ca2 Mon Sep 17 00:00:00 2001 From: sdogruyol Date: Wed, 13 Jan 2016 10:07:37 +0200 Subject: [PATCH] Refactor parse_url_params --- src/kemal/param_parser.cr | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/kemal/param_parser.cr b/src/kemal/param_parser.cr index 43ae3cc..c74ea70 100644 --- a/src/kemal/param_parser.cr +++ b/src/kemal/param_parser.cr @@ -35,18 +35,15 @@ class Kemal::ParamParser parse_part(@request.query) end + # Ditto: This needs memoization without the huge AllParamTypes union :| def parse_url_params - url_params = @request.url_params - begin - url_params = url_params.not_nil! + if @request.url_params + url_params = @request.url_params.not_nil! name_table = url_params.regex.name_table - size = url_params.size - size.times do |i| - name = name_table.fetch(i + 1) { i + 1 } - value = url_params[i + 1] - @params[name as String] = value + url_params.size.times do |i| + name = (name_table.fetch(i + 1) { i + 1 }) as String + @params[name] = url_params[i + 1] end - rescue end end