[test] Optimize offset->line in kondo-ratchet test (#79931)
This commit is contained in:
committed by
GitHub
parent
073e520171
commit
db6e70c620
@@ -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`."
|
||||
|
||||
Reference in New Issue
Block a user