minor microoptimizations

This commit is contained in:
XeroOl 2024-02-17 22:38:25 -06:00
parent 21500707de
commit 67b1fbfbef
3 changed files with 10 additions and 10 deletions

View File

@ -20,7 +20,7 @@
;; LSP line numbers are zero-indexed, but Emacs and Vim both use ;; LSP line numbers are zero-indexed, but Emacs and Vim both use
;; 1-indexing for this. ;; 1-indexing for this.
(+ (or start.line 0) 1) (or start.character "?") message))) (+ (or start.line 0) 1) (or start.character "?") message)))
(if (not= 0 (length file.diagnostics)) (if (. file.diagnostics 1)
(set should-err? true)))) (set should-err? true))))
(if should-err? (if should-err?
(os.exit 1)))) (os.exit 1))))

View File

@ -137,9 +137,8 @@ identifiers are declared / referenced in which places."
{:binding symbol {:binding symbol
:definition ?definition :definition ?definition
:referenced-by (or (?. definitions symbol :referenced-by) []) :referenced-by (or (?. definitions symbol :referenced-by) [])
:keys (if (< 0 (length keys)) :keys (if (. keys 1)
(fcollect [i 1 (length keys)] (icollect [_ v (ipairs keys)] v))
(. keys i)))
:multival ?multival :multival ?multival
:var? (?. ?opts :isvar) :var? (?. ?opts :isvar)
: file}] : file}]

View File

@ -175,12 +175,13 @@ a user-written file.
"find a definition just from the name of the item, and the scope it is in" "find a definition just from the name of the item, and the scope it is in"
(assert (= (type name) :string)) (assert (= (type name) :string))
(let [stack (stack-add-multisym! [] name)] (let [stack (stack-add-multisym! [] name)]
(case (. METADATA (or (. MACROS name) (. SPECIALS name))) (or
metadata {:binding (sym name) : metadata} (case (. METADATA (or (. MACROS name) (. SPECIALS name)))
_ (case (global-info self name) metadata {:binding (sym name) : metadata})
global-item global-item (case (global-info self name)
_ (case (find-local-definition file name scope) global-item global-item)
def (search-val self file def.definition (stack-add-keys! stack def.keys) (or ?opts {}))))))) (case (find-local-definition file name scope)
def (search-val self file def.definition (stack-add-keys! stack def.keys) (or ?opts {}))))))
(λ _past? [?ast byte] (λ _past? [?ast byte]
;; check if a byte is past an ast object ;; check if a byte is past an ast object