Skip to content

Commit ea9e4fa

Browse files
committed
Use java.util.HexFormat to convert bytes to hex strings
Added in JDK 17
1 parent e6bb9eb commit ea9e4fa

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/net/lewisship/cli_tools/cache.cljc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[clj-commons.ansi :refer [perr]]
1010
#?(:bb [babashka.classpath :as cp]))
1111
(:import (java.io File)
12+
(java.util HexFormat)
1213
(java.nio ByteBuffer)
1314
(java.security MessageDigest)))
1415

@@ -58,10 +59,10 @@
5859
;; Adding or removing a file (even if no other files are touched) will change the digest.
5960
(update-digest-recursively digest f))))
6061

61-
(defn- hex-string [^bytes input]
62-
(let [sb (StringBuilder.)]
63-
(run! #(.append sb (format "%X" %)) input)
64-
(str sb)))
62+
(defn- hex-string
63+
[^bytes input]
64+
(-> (HexFormat/of)
65+
(.formatHex input)))
6566

6667
(defn classpath-digest
6768
"Passed the tool options, return a hex string of the SHA-1 digest of the files from the classpath and

0 commit comments

Comments
 (0)