Finalize Trie & cleanup

This commit is contained in:
Tommi Reiman 2019-03-03 20:19:27 +02:00
parent a44267ba85
commit 59560860d8
3 changed files with 5 additions and 24 deletions

View file

@ -40,7 +40,7 @@ public class Trie {
public static class Match { public static class Match {
public IPersistentMap params; public IPersistentMap params;
public Object data; public final Object data;
public Match(IPersistentMap params, Object data) { public Match(IPersistentMap params, Object data) {
this.params = params; this.params = params;
@ -68,7 +68,7 @@ public class Trie {
return new StaticMatcher(path, child); return new StaticMatcher(path, child);
} }
static class StaticMatcher implements Matcher { static final class StaticMatcher implements Matcher {
private final Matcher child; private final Matcher child;
private final char[] path; private final char[] path;
private final int size; private final int size;
@ -238,7 +238,6 @@ public class Trie {
} }
static final class LinearMatcher implements Matcher { static final class LinearMatcher implements Matcher {
private final Matcher[] childs; private final Matcher[] childs;
private final int size; private final int size;

View file

@ -68,7 +68,7 @@
(recur ss from (inc to)) (recur ss from (inc to))
(recur (concat ss (-static from to) (-wild to to')) (long to') (long to')))) (recur (concat ss (-static from to) (-wild to to')) (long to') (long to'))))
\* (let [to' (count s)] \* (let [to' (count s)]
(recur (concat ss (-static from to) (-catch-all to to')) to' to')) (recur (concat ss (-static from to) (-catch-all to to')) (long to') (long to')))
(recur ss from (inc to))))))) (recur ss from (inc to)))))))
(defn join-path [xs] (defn join-path [xs]
@ -405,21 +405,4 @@
["/v1/orgs/:org-id/topics" 57]] ["/v1/orgs/:org-id/topics" 57]]
(insert) (insert)
(compile) (compile)
(pretty) (pretty)))
(./aprint))
(-> [["/{a}/2"]
["/{a}.2"]]
(insert)
(compile))
(-> [["/kikka" 2]
["/kikka/kakka/kukka" 3]
["/kikka/:kakka/kurkku" 4]
["/kikka/kuri/{user/doc}/html" 5]]
(insert)
(compile)
(pretty))
(map str (.toCharArray "\u2215\u0048\u0065\u006C\u006C\u006F"))
(count ["" "H" "e" "l" "l" "o" " " "W" "o" "r" "l" "d"]))

View file

@ -15,8 +15,7 @@
[io.pedestal.http.route.map-tree :as map-tree] [io.pedestal.http.route.map-tree :as map-tree]
[io.pedestal.http.route.router :as pedestal] [io.pedestal.http.route.router :as pedestal]
[reitit.core :as r] [reitit.core :as r]
[criterium.core :as cc] [criterium.core :as cc]))
[reitit.trie :as trie]))
;; ;;
;; start repl with `lein perf repl` ;; start repl with `lein perf repl`