Skip to content

Resolve reflection in optimizations ns #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Fixed

- Resolved reflection in `lambdaisland.clj-diff.optimizations`

## Changed

# 1.4.78 (2022-11-25 / 2c3cae0)
Expand Down Expand Up @@ -39,4 +41,4 @@

# 1.1.55 (2020-08-19 / 77da754)

First release of the lambdaisland/clj-diff fork of clj-diff.
First release of the lambdaisland/clj-diff fork of clj-diff.
2 changes: 1 addition & 1 deletion bin/kaocha
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
clojure -A:dev:test -m kaocha.runner "$@"
clojure -M:dev:test -m kaocha.runner "$@"
4 changes: 3 additions & 1 deletion src/clj/lambdaisland/clj_diff/optimizations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
See http://neil.fraser.name/writing/diff/."
(:import lambdaisland.clj_diff.FastStringOps))

(set! *warn-on-reflection* true)

(defn common-prefix [^String a ^String b]
(let [i (FastStringOps/commonPrefix a b)]
[i (.substring a i) (.substring b i)]))
Expand All @@ -17,7 +19,7 @@
"Return a diff if the shorter sequence exists in the longer one. No need to
use the expensive diff algorithm for this."
[^String a ^String b ^Integer ca ^Integer cb]
(let [[short long] (if (> ca cb) [b a] [a b])
(let [[^String short ^String long] (if (> ca cb) [b a] [a b])
i (int (.indexOf long short))]
(if (= i -1)
nil
Expand Down