Skip to content

Commit a158b26

Browse files
committed
org-export-data: Concatenate strings in temporary buffer for performance
* lisp/ox.el (org-export-data): Use temporary buffer to collect export data instead of `mapconcat'. Using buffer puts less load on garbage collector.
1 parent 3684c79 commit a158b26

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

lisp/ox.el

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,28 +1924,34 @@ Return a string."
19241924
(and (not greaterp)
19251925
(memq type org-element-recursive-objects)))
19261926
(contents
1927-
(mapconcat
1928-
(lambda (element) (org-export-data element info))
1929-
(org-element-contents
1930-
(if (or greaterp objectp) data
1931-
;; Elements directly containing
1932-
;; objects must have their indentation
1933-
;; normalized first.
1934-
(org-element-normalize-contents
1935-
data
1936-
;; When normalizing first paragraph
1937-
;; of an item or
1938-
;; a footnote-definition, ignore
1939-
;; first line's indentation.
1940-
(and
1941-
(eq type 'paragraph)
1942-
(memq (org-element-type parent)
1943-
'(footnote-definition item))
1944-
(eq (car (org-element-contents parent))
1945-
data)
1946-
(eq (org-element-property :pre-blank parent)
1947-
0)))))
1948-
"")))
1927+
(let ((export-buffer (current-buffer)))
1928+
(with-temp-buffer
1929+
(dolist (element (org-element-contents
1930+
(if (or greaterp objectp) data
1931+
;; Elements directly containing
1932+
;; objects must have their indentation
1933+
;; normalized first.
1934+
(org-element-normalize-contents
1935+
data
1936+
;; When normalizing first paragraph
1937+
;; of an item or
1938+
;; a footnote-definition, ignore
1939+
;; first line's indentation.
1940+
(and
1941+
(eq type 'paragraph)
1942+
(memq (org-element-type parent)
1943+
'(footnote-definition item))
1944+
(eq (car (org-element-contents parent))
1945+
data)
1946+
(eq (org-element-property :pre-blank parent)
1947+
0))))))
1948+
(insert
1949+
;; Use right local variable
1950+
;; environment if there are, for
1951+
;; example, #+BIND variables.
1952+
(with-current-buffer export-buffer
1953+
(org-export-data element info))))
1954+
(buffer-string)))))
19491955
(broken-link-handler
19501956
(funcall transcoder data
19511957
(if (not greaterp) contents

0 commit comments

Comments
 (0)