Skip to content

Commit

Permalink
Backport commit 979308b4c from Emacs
Browse files Browse the repository at this point in the history
* lisp/ox.el (org-export-data): Use temporary buffer to collect export
data instead of `mapconcat'.  Using buffer puts less load on garbage
collector.

org-export-data: Concatenate strings in temporary buffer for performance
979308b4cad2b573606ed71a1689a47a9e7a9e98
Ihor Radchenko
Thu Jun 16 10:53:51 2022 +0300

[ km: This ported commit comes from main's a158b26 and was reverted
  in 811deae.  I'm applying it here too for bookkeeping/traceability
  purposes, but these changes will be discarded when merged with
  main. ]
  • Loading branch information
yantar92 authored and kyleam committed Oct 4, 2022
1 parent 4ae72c6 commit 8ac9203
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions lisp/ox.el
Original file line number Diff line number Diff line change
Expand Up @@ -1925,28 +1925,34 @@ Return a string."
(and (not greaterp)
(memq type org-element-recursive-objects)))
(contents
(mapconcat
(lambda (element) (org-export-data element info))
(org-element-contents
(if (or greaterp objectp) data
;; Elements directly containing
;; objects must have their indentation
;; normalized first.
(org-element-normalize-contents
data
;; When normalizing first paragraph
;; of an item or
;; a footnote-definition, ignore
;; first line's indentation.
(and
(eq type 'paragraph)
(memq (org-element-type parent)
'(footnote-definition item))
(eq (car (org-element-contents parent))
data)
(eq (org-element-property :pre-blank parent)
0)))))
"")))
(let ((export-buffer (current-buffer)))
(with-temp-buffer
(dolist (element (org-element-contents
(if (or greaterp objectp) data
;; Elements directly containing
;; objects must have their indentation
;; normalized first.
(org-element-normalize-contents
data
;; When normalizing first paragraph
;; of an item or
;; a footnote-definition, ignore
;; first line's indentation.
(and
(eq type 'paragraph)
(memq (org-element-type parent)
'(footnote-definition item))
(eq (car (org-element-contents parent))
data)
(eq (org-element-property :pre-blank parent)
0))))))
(insert
;; Use right local variable
;; environment if there are, for
;; example, #+BIND variables.
(with-current-buffer export-buffer
(org-export-data element info))))
(buffer-string)))))
(broken-link-handler
(funcall transcoder data
(if (not greaterp) contents
Expand Down

0 comments on commit 8ac9203

Please sign in to comment.