From: Vladimir Sedach Date: Sun, 13 Sep 2009 22:04:53 +0000 (-0600) Subject: Changed op-precedence back to a memoized table (performance tweaks). X-Git-Url: https://git.hcoop.net/clinton/parenscript.git/commitdiff_plain/4a56eb79eed989dcfa42988b53d271b0627a3908 Changed op-precedence back to a memoized table (performance tweaks). --- diff --git a/src/compiler.lisp b/src/compiler.lisp index 30bd35d..9fbba55 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -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