Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

[test] Optimize offset->line in kondo-ratchet test (#79931)

Oleksandr Yakushevdb6e70c620d6
diff --git a/dev/src/dev/kondo_ratchet.clj b/dev/src/dev/kondo_ratchet.clj
index 7acbcc43b21..4de5c90739c 100644
--- a/dev/src/dev/kondo_ratchet.clj
+++ b/dev/src/dev/kondo_ratchet.clj
@@ -518,7 +518,7 @@
(defn- offset->line
"1-based line number of character offset `i` in `content`."
[content i]
- (inc (count (filter #(= % \newline) (subs content 0 i)))))
+ (reduce (fn [cnt c] (cond-> cnt (= c \newline) inc)) 1 (subs content 0 i)))
(defn- matches-with-offsets
"Like re-seq, but returns `{:start _, :end _, :linters [...]}` for each match of `re` in `masked`."