Skip to content

Commit

Permalink
Fix some reflection and performamce warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
egli committed Aug 28, 2024
1 parent 5b93a20 commit 8d7d542
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/clj/daisyproducer2/hyphenate.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
:stop
(when hyphenators
(doseq [[_ hyphenator] hyphenators]
(.close hyphenator))))
(.close ^Hyphenator hyphenator))))

(defn- hyphenate*
"Hyphenate given `text` using a given `hyphenator`"
[text hyphenator]
[text ^Hyphenator hyphenator]
(if (string/blank? text)
""
(.hyphenate hyphenator text \- nil)))
Expand Down
2 changes: 1 addition & 1 deletion src/clj/daisyproducer2/louis.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
(let [tables-string (apply str (interpose \, tables))]
(Translator. ^String tables-string)))

(defn translate [word translator]
(defn translate [word ^Translator translator]
(let [length (count word)
inter-character-attributes (int-array (repeat (- length 1) 0))]
(try
Expand Down
5 changes: 3 additions & 2 deletions src/clj/daisyproducer2/whitelists/tables.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[daisyproducer2.louis :as louis]
[daisyproducer2.metrics :as metrics]
[daisyproducer2.words :as words]
[iapetos.collector.fn :as prometheus]))
[iapetos.collector.fn :as prometheus])
(:import java.io.BufferedWriter))

(def ascii-to-dots
{\A "1"
Expand Down Expand Up @@ -184,7 +185,7 @@
document-extension (if identifier (str "-" identifier) "")]
(format "%s/sbs-de-%s-white%s.mod" tables-dir key document-extension)))

(defn write-table [w grade translate words]
(defn write-table [^BufferedWriter w grade translate words]
(doseq [{:keys [untranslated uncontracted contracted homograph-disambiguation] :as word} words]
(let [untranslated (if (words/is-homograph? word)
(string/replace homograph-disambiguation "|" words/braille-dummy-text)
Expand Down
4 changes: 2 additions & 2 deletions src/clj/daisyproducer2/words.clj
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
(assoc :contracted (louis/translate untranslated (louis/translator (louis/get-tables 2 params)))))))

(defn grades [grade]
(case grade ; convert grade into a list of grades
(case (int grade) ; convert grade into a list of grades
(1 2) [grade] ; for grade 1 and 2 the list contains just that grade
0 [1 2])) ; grade 0 really means both grades

Expand Down Expand Up @@ -104,7 +104,7 @@
(rename-keys mapping)))

(defn- value-to-boolean [v]
(case v
(case (int v)
1 true
0 false
v))
Expand Down
2 changes: 1 addition & 1 deletion src/clj/daisyproducer2/words/confirm.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
;; do the deletion using the old type, otherwise we will
;; not find it.
type (:type word)
old-type (case type
old-type (case (int type)
1 2 ; if :type-name-hoffmann it was previously :type-name
3 4 ; if :type-place-langenthal it was previously :type-place
type)
Expand Down

0 comments on commit 8d7d542

Please sign in to comment.