From 4273ab34c484f38fa9f77d133cd83256d721e7c8 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Sun, 25 Dec 2016 01:03:02 +1030 Subject: Shave a couple of allocations off Journey scan & parse --- actionpack/lib/action_dispatch/journey/scanner.rb | 30 ++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'actionpack/lib/action_dispatch/journey/scanner.rb') diff --git a/actionpack/lib/action_dispatch/journey/scanner.rb b/actionpack/lib/action_dispatch/journey/scanner.rb index 4b8c8ab063..7dbb39b26d 100644 --- a/actionpack/lib/action_dispatch/journey/scanner.rb +++ b/actionpack/lib/action_dispatch/journey/scanner.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "strscan" module ActionDispatch @@ -35,22 +36,23 @@ module ActionDispatch def scan case # / - when text = @ss.scan(/\//) - [:SLASH, text] + when @ss.skip(/\//) + [:SLASH, "/"] + when @ss.skip(/\(/) + [:LPAREN, "("] + when @ss.skip(/\)/) + [:RPAREN, ")"] + when @ss.skip(/\|/) + [:OR, "|"] + when @ss.skip(/\./) + [:DOT, "."] + when text = @ss.scan(/:\w+/) + [:SYMBOL, text] when text = @ss.scan(/\*\w+/) [:STAR, text] - when text = @ss.scan(/(?