Skip to content

Commit d0e357a

Browse files
committed
Combine calls to replace-regexp-in-string
Profiling shows we end up performing a lot of allocations in this section of code. Minimise string allocations by combining the two platform-specific newline regexps into one.
1 parent 173e2ad commit d0e357a

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

nrepl-client.el

+1-4
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,7 @@ object is a root list or dict."
326326
(goto-char end)
327327
;; normalise any platform-specific newlines
328328
(let* ((original (buffer-substring-no-properties beg end))
329-
;; handle both \n\r and \r\n
330-
(result (replace-regexp-in-string "\r\n\\|\n\r" "\n" original))
331-
;; we don't handle single carriage returns, insert newline
332-
(result (replace-regexp-in-string "\r" "\n" result)))
329+
(result (replace-regexp-in-string "\r\n\\|\n\r\\|\r" "\n" original)))
333330
(cons nil (nrepl--push result stack))))))
334331
;; integer
335332
((looking-at "i\\(-?[0-9]+\\)e")

0 commit comments

Comments
 (0)