Skip to content
Snippets Groups Projects
Unverified Commit 887e8bf4 authored by Cam Saul's avatar Cam Saul Committed by GitHub
Browse files

11x faster pretty printing (#35897)

parent 3841a666
Branches
Tags
No related merge requests found
......@@ -137,11 +137,13 @@
clojure.pprint/pprint {:message "Use metabase.util.log instead of clojure.pprint/pprint"}
clojure.string/lower-case {:message "Use metabase.util/lower-case-en instead of clojure.string/lower-case"}
clojure.string/upper-case {:message "Use metabase.util/upper-case-en instead of clojure.string/upper-case"}
fipp.edn/pprint {:message "Use metabase.util.log instead of fipp.edn/pprint"}
honeysql.core/call {:message "Use hx/call instead because it is Honey SQL 2 friendly"}
honeysql.core/raw {:message "Use hx/raw instead because it is Honey SQL 2 friendly"}
java-time/with-clock {:message "Use mt/with-clock"}
java.util.UUID/randomUUID {:message "Use clojure.core/random-uuid instead of java.util.UUID/randomUUID"}
malli.core/explainer {:message "Use metabase.util.malli.registry/explainer instead of malli.core/explainer"}
me.flowthing.pp/pprint {:message "Use metabase.util.log instead of me.flowthing.pp/pprint"}
medley.core/random-uuid {:message "Use clojure.core/random-uuid instead of medley.core/random-uuid"}
metabase.lib.equality/find-column-indexes-for-refs {:message "Use lib.equality/closest-matches-in-metadata or lib.equality/find-closest-matches-for-refs instead of lib.equality/find-column-indexes-for-refs"}
metabase.test/with-temp* {:message "Use mt/with-temp instead of mt/with-temp*"}
......
......@@ -74,6 +74,8 @@
instaparse/instaparse {:mvn/version "1.4.12"} ; Make your own parser
clj-commons/clj-yaml {:mvn/version "1.0.27"} ; Clojure wrapper for YAML library SnakeYAML
io.github.camsaul/toucan2 {:mvn/version "1.0.524"}
io.github.eerohele/pp {:git/tag "2023-10-05.5" ; super fast pretty-printing library
:git/sha "7059eec"}
;; The 2.X line of Resilience4j requires Java 17, so we cannot upgrade this dependency until that is our minimum JVM version
io.github.resilience4j/resilience4j-retry {:mvn/version "1.7.1"} ; Support for retrying operations
io.prometheus/simpleclient_hotspot {:mvn/version "0.16.0"} ; prometheus jvm collector
......
......@@ -17,6 +17,7 @@
[net.cgrand.macrovich :as macros]
[weavejester.dependency :as dep]
#?@(:clj ([clojure.math.numeric-tower :as math]
[me.flowthing.pp :as pp]
[metabase.config :as config]
#_{:clj-kondo/ignore [:discouraged-namespace]}
[metabase.util.jvm :as u.jvm]
......@@ -615,12 +616,19 @@
(pprint-to-str 'green some-obj)"
(^String [x]
;; we try to set this permanently above, but it doesn't seem to work in Cljs, so just bind it every time. The
;; default value wastes too much space, 120 is a little easier to read actually.
(#?@(:clj [do] :cljs [binding [pprint/*print-right-margin* 120]])
(#?@
(:clj
(with-out-str
#_{:clj-kondo/ignore [:discouraged-var]}
(pprint/pprint x))))
(pp/pprint x {:max-width 120}))
:cljs
;; we try to set this permanently above, but it doesn't seem to work in Cljs, so just bind it every time. The
;; default value wastes too much space, 120 is a little easier to read actually.
(binding [pprint/*print-right-margin* 120]
(with-out-str
#_{:clj-kondo/ignore [:discouraged-var]}
(pprint/pprint x))))))
(^String [color-symb x]
(u.format/colorize color-symb (pprint-to-str x))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment