Skip to content

Commit e22a500

Browse files
committed
Merge pull request weavejester#6 from amalloy/master
Remove reflection
2 parents b1f93e9 + 4647aea commit e22a500

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/clout/core.clj

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"Library for parsing the Rails routes syntax."
33
(:require [clojure.string :as string])
44
(:import java.util.Map
5+
java.util.regex.Matcher
56
[java.net URLDecoder URLEncoder]))
67

78
;; Regular expression utilties
@@ -19,9 +20,9 @@
1920
(defn re-groups*
2021
"More consistant re-groups that always returns a vector of groups, even if
2122
there is only one group."
22-
[matcher]
23+
[^Matcher matcher]
2324
(for [i (range (.groupCount matcher))]
24-
(.group matcher (inc i))))
25+
(.group matcher (int (inc i)))))
2526

2627
;; Route matching
2728

@@ -94,7 +95,7 @@
9495
(let [matcher (re-matcher re src)]
9596
(if (.lookingAt matcher)
9697
[(if (fn? action) (action matcher) action)
97-
(.substring src (.end matcher))])))
98+
(subs src (.end matcher))])))
9899
(partition 2 clauses)))
99100

100101
(defn- lex
@@ -123,15 +124,15 @@
123124
(let [splat #"\*"
124125
word #":([\p{L}_][\p{L}_0-9-]*)"
125126
literal #"(:[^\p{L}_*]|[^:*])+"
126-
word-group #(keyword (.group % 1))
127+
word-group #(keyword (.group ^Matcher % 1))
127128
word-regex #(regexs (word-group %) "[^/,;?]+")]
128129
(CompiledRoute.
129130
(re-pattern
130131
(apply str
131132
(lex path
132133
splat "(.*?)"
133134
word #(str "(" (word-regex %) ")")
134-
literal #(re-escape (.group %)))))
135+
literal #(re-escape (.group ^Matcher %)))))
135136
(remove nil?
136137
(lex path
137138
splat :*

0 commit comments

Comments
 (0)