Skip to content

Commit

Permalink
Remove unnecessary binding of current message (#736)
Browse files Browse the repository at this point in the history
The binding is not used within the body expressions, and costs a thread
local binding, producing garbage.  This changes ensures print-stream
produces no memory garbage.

The forking-printer just takes values and forwards them. There is no execution of user code, so it can not possibly use the message in any. print-stream invokes the forking printer flush every 100ms, so the current code produces garbage every 100ms.
  • Loading branch information
hugoduncan authored Dec 10, 2021
1 parent df6b5c6 commit 9dc1b38
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/cider/nrepl/middleware/out.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
guarantee that the channel that sent the clone message will properly
handle output replies."
(:require
[cider.nrepl.middleware.util.error-handling :refer [with-safe-transport]]
[nrepl.middleware.interruptible-eval :as ieval])
[cider.nrepl.middleware.util.error-handling :refer [with-safe-transport]])
(:import
[java.io PrintWriter Writer PrintStream OutputStream]
[java.util TimerTask Timer]))
Expand All @@ -34,11 +33,11 @@ Please do not inline; they must not be recomputed at runtime."}
(case ~type
:out #'*out*
:err #'*err*))]
(try (binding [ieval/*msg* ~'msg]
~@body)
;; If a channel is faulty, dissoc it.
(catch Exception ~'e
(unsubscribe-session ~'session))))))
(try
~@body
;; If a channel is faulty, dissoc it.
(catch Exception ~'e
(unsubscribe-session ~'session))))))

(defn- dispatch-string
([messages type ^String x]
Expand Down

0 comments on commit 9dc1b38

Please sign in to comment.