From 67b1fbfbef8122026647b54a7eca35572d857b8f Mon Sep 17 00:00:00 2001 From: XeroOl Date: Sat, 17 Feb 2024 22:38:25 -0600 Subject: [PATCH] minor microoptimizations --- src/fennel-ls.fnl | 2 +- src/fennel-ls/compiler.fnl | 5 ++--- src/fennel-ls/language.fnl | 13 +++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/fennel-ls.fnl b/src/fennel-ls.fnl index ea9b59c..7a64f9a 100644 --- a/src/fennel-ls.fnl +++ b/src/fennel-ls.fnl @@ -20,7 +20,7 @@ ;; LSP line numbers are zero-indexed, but Emacs and Vim both use ;; 1-indexing for this. (+ (or start.line 0) 1) (or start.character "?") message))) - (if (not= 0 (length file.diagnostics)) + (if (. file.diagnostics 1) (set should-err? true)))) (if should-err? (os.exit 1)))) diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index 5e40e41..2aee1b8 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -137,9 +137,8 @@ identifiers are declared / referenced in which places." {:binding symbol :definition ?definition :referenced-by (or (?. definitions symbol :referenced-by) []) - :keys (if (< 0 (length keys)) - (fcollect [i 1 (length keys)] - (. keys i))) + :keys (if (. keys 1) + (icollect [_ v (ipairs keys)] v)) :multival ?multival :var? (?. ?opts :isvar) : file}] diff --git a/src/fennel-ls/language.fnl b/src/fennel-ls/language.fnl index 06cd8de..8022f34 100644 --- a/src/fennel-ls/language.fnl +++ b/src/fennel-ls/language.fnl @@ -175,12 +175,13 @@ a user-written file. "find a definition just from the name of the item, and the scope it is in" (assert (= (type name) :string)) (let [stack (stack-add-multisym! [] name)] - (case (. METADATA (or (. MACROS name) (. SPECIALS name))) - metadata {:binding (sym name) : metadata} - _ (case (global-info self name) - global-item global-item - _ (case (find-local-definition file name scope) - def (search-val self file def.definition (stack-add-keys! stack def.keys) (or ?opts {}))))))) + (or + (case (. METADATA (or (. MACROS name) (. SPECIALS name))) + metadata {:binding (sym name) : metadata}) + (case (global-info self name) + global-item global-item) + (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] ;; check if a byte is past an ast object