Changed op-precedence back to a memoized table (performance tweaks).
authorVladimir Sedach <vsedach@gmail.com>
Sun, 13 Sep 2009 22:04:53 +0000 (16:04 -0600)
committerVladimir Sedach <vsedach@gmail.com>
Sun, 13 Sep 2009 22:04:53 +0000 (16:04 -0600)
src/compiler.lisp

index 30bd35d..9fbba55 100644 (file)
@@ -209,25 +209,29 @@ the form cannot be compiled to a symbol."
 
 ;;; operators
 
-(defun op-precedence (op)
-  (position op
-            '((js:new js:slot-value js:aref)
-              (postfix++ postfix--)
-              (delete void typeof ++ -- unary+ unary- ~ !)
-              (* / %)
-              (+ -)
-              (<< >> >>>)
-              (< > <= >= js:instanceof js:in)
-              (== != === !==)
-              (&)
-              (^)
-              (\|)
-              (\&\& and)
-              (\|\| or)
-              (js:?)
-              (= *= /= %= += -= <<= >>= >>>= \&\= ^= \|=)
-              (comma))
-            :test #'member))
+(let ((precedence-table (make-hash-table :test 'eq)))
+  (loop for level in '((js:new js:slot-value js:aref)
+                       (postfix++ postfix--)
+                       (delete void typeof ++ -- unary+ unary- ~ !)
+                       (* / %)
+                       (+ -)
+                       (<< >> >>>)
+                       (< > <= >= js:instanceof js:in)
+                       (== != === !==)
+                       (&)
+                       (^)
+                       (\|)
+                       (\&\& and)
+                       (\|\| or)
+                       (js:?)
+                       (= *= /= %= += -= <<= >>= >>>= \&\= ^= \|=)
+                       (comma))
+     for i from 0
+     do (mapcar (lambda (symbol)
+                  (setf (gethash symbol precedence-table) i))
+                level))
+  (defun op-precedence (op)
+    (gethash op precedence-table)))
 
 (defun ps-convert-op-name (op)
   (case op