Permalink
Browse files

Token view

  • Loading branch information...
laurentpetit committed Aug 14, 2011
1 parent 2c7d791 commit 42fd92e723741cef92aab024130c2b4a2de85e55
Showing with 325 additions and 115 deletions.
  1. +2 −2 .settings/ccw.repl.cmdhistory.prefs
  2. +1 −1 META-INF/MANIFEST.MF
  3. +66 −0 TIMINGS
  4. +2 −3 src/paredit/core.clj
  5. +0 −11 src/paredit/loc_utils.clj
  6. +219 −98 src/paredit/parser.clj
  7. +35 −0 src/paredit/utils.clj

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Paredit.clj
Bundle-SymbolicName: paredit.clj;singleton:=true
-Bundle-Version: 0.13.1.STABLE001
+Bundle-Version: 0.13.2.I003
Bundle-ClassPath: .,
classes/
Bundle-ActivationPolicy: lazy
View
66 TIMINGS
@@ -0,0 +1,66 @@
+Every timings, unless stated otherwise, have count, cumulative count, and tokens.
+
+a) without views
+================
+
+==== Executing full parser:
+"Elapsed time: 153.142947 msecs"
+full parser's tokens first and second walks:
+"Elapsed time: 76.132462 msecs"
+"Elapsed time: 8.579688 msecs"
+==== Executing parser incrementally:
+"Elapsed time: 285.073983 msecs"
+incremental full parser's tokens first and second walks:
+"Elapsed time: 78.428949 msecs"
+"Elapsed time: 9.518916 msecs"
+==== initial incremental buffer
+"Elapsed time: 23.664681 msecs"
+initial parse-tree
+"Elapsed time: 257.943785 msecs"
+parse-tree via the function, again (should be instantaneous)
+"Elapsed time: 1.020832 msecs"
+tokens first walk:
+"Elapsed time: 82.010332 msecs"
+tokens second walk:
+"Elapsed time: 10.575161 msecs"
+==== add '(\n' before the top comment
+"Elapsed time: 0.220564 msecs"
+parse-tree after add '(\n' before the top comment
+"Elapsed time: 116.526167 msecs"
+parse-tree via the function, again (should be instantaneous)
+"Elapsed time: 0.831447 msecs"
+"Elapsed time: 71.758896 msecs"
+tokens second walk:
+"Elapsed time: 8.715568 msecs"
+
+b) with view machinery, still count, tokens, cumulative count with single pass
+=============
+==== Executing full parser:
+"Elapsed time: 268.080511 msecs"
+full parser's tokens first and second walks:
+"Elapsed time: 76.782607 msecs"
+"Elapsed time: 8.70633 msecs"
+==== Executing parser incrementally:
+"Elapsed time: 267.433445 msecs"
+incremental full parser's tokens first and second walks:
+"Elapsed time: 78.53442 msecs"
+"Elapsed time: 9.65287 msecs"
+==== initial incremental buffer
+"Elapsed time: 23.175435 msecs"
+initial parse-tree
+"Elapsed time: 279.681895 msecs"
+parse-tree via the function, again (should be instantaneous)
+"Elapsed time: 1.155943 msecs"
+tokens first walk:
+"Elapsed time: 80.119559 msecs"
+tokens second walk:
+"Elapsed time: 10.075523 msecs"
+==== add '(\n' before the top comment
+"Elapsed time: 0.288312 msecs"
+parse-tree after add '(\n' before the top comment
+"Elapsed time: 109.810692 msecs"
+parse-tree via the function, again (should be instantaneous)
+"Elapsed time: 1.505074 msecs"
+"Elapsed time: 68.057801 msecs"
+tokens second walk:
+"Elapsed time: 8.487689 msecs"
View
@@ -22,7 +22,6 @@
(:use paredit.loc-utils)) ; TODO avoir un require :as l
#_(set! *warn-on-reflection* true)
-
;;; adaptable paredit configuration
(def ^String *newline* "\n")
;;; adaptable paredit configuration
@@ -224,7 +223,7 @@
(let [offset-loc (-> parsed parsed-root-loc (loc-for-offset offset))
handled-forms *brackets-tags*
in-handled-form (handled-forms (loc-tag offset-loc))
- open-punct-length (.length (first (:content (z/node offset-loc))))]
+ open-punct-length (.length ^String (first (:content (z/node offset-loc))))]
(cond
(and in-handled-form (= offset (start-offset offset-loc)))
(t/shift-offset t open-punct-length)
@@ -274,7 +273,7 @@
for while do doto try catch locking dosync doseq dorun doall
-> -?> ->> future ns clojure.core/ns gen-class gen-interface))))
(defn ^{:doc "Returns logical true if the String probably names a special form or macro var"}
- lisp-form? [s]
+ lisp-form? [^String s]
(or
(.startsWith s "def")
(.startsWith s "with")
View
@@ -4,7 +4,6 @@
(:require [clojure.contrib.zip-filter :as zf]))
#_(set! *warn-on-reflection* true)
-
(defn xml-vzip
"Returns a zipper for xml elements (as from xml/parse),
given a root element"
@@ -205,16 +204,6 @@
:else l))
(root-loc loc)))
-#_(defn loc-containing-offset
- ([loc offset]
- (if (= 0 offset)
- (root-loc loc)
- (let [match (some #(contains-offset? % offset) (take-while (complement zip/end?) (iterate zip/next (zip/next (root-loc loc)))))]
- (cond
- (nil? match) (root-loc loc)
- (= offset (start-offset match)) (zip/up match)
- :else match)))))
-
(defn start-punct?
"true if the loc is a punct starting a form"
[loc]
Oops, something went wrong.

0 comments on commit 42fd92e

Please sign in to comment.