summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJambunathan K <kjambunathan@gmail.com>2011-11-24 23:46:34 +0530
committerJambunathan K <kjambunathan@gmail.com>2011-11-24 23:46:57 +0530
commit2ded8ccb8505961687dd7c5ba025e0ebed5bb89b (patch)
treefd03003083af910ac4cbed9731d33266533b9a09
parent5a24ffe004bacac719f4753c6f9b801e6e15fcd9 (diff)
downloadorg-mode-2ded8ccb8505961687dd7c5ba025e0ebed5bb89b.tar.gz
org-odt.el: Fix performance issue on manifest file writing
* contrib/lisp/org-odt.el (org-odt-write-manifest-file): Don't use write-region. The org-odt-write-manifest-file function take too much time - several seconds for 164 files. This patch provides a cheaper implementation (hundredths of a seconds for 164 files). Original patch by Jérémy Compostella <jeremy.compostella@gmail.com>. Rewritten by Jambunathan K to minimize the actual number of lines changed. TINYCHANGE. From http://www.mail-archive.com/emacs-orgmode@gnu.org/msg49248.html I'm currently generating a road book for a trip from different Org-Mode file and other data. It results in a 13 thousands lines Org-Mode file and I have some performance issues. Using the ELP package, I isolated the two main bottlenecks. One is in org-odt : the org-odt-write-manifest-file function is called once and takes 5.546672 seconds to write a 167 lines file. I rewrote this function and now it takes 0.01606 seconds to write the same file.
-rw-r--r--contrib/lisp/org-odt.el31
1 files changed, 16 insertions, 15 deletions
diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el
index 137a4d5..944b5b2 100644
--- a/contrib/lisp/org-odt.el
+++ b/contrib/lisp/org-odt.el
@@ -1959,21 +1959,22 @@ visually."
(defun org-odt-write-manifest-file ()
(make-directory "META-INF")
(let ((manifest-file (expand-file-name "META-INF/manifest.xml")))
- (write-region
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
- <manifest:manifest xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\" manifest:version=\"1.2\">\n"
- nil manifest-file)
- (mapc
- (lambda (file-entry)
- (let* ((version (nth 2 file-entry))
- (extra (if version
- (format " manifest:version=\"%s\"" version)
- "")))
- (write-region
- (format org-odt-manifest-file-entry-tag
- (nth 0 file-entry) (nth 1 file-entry) extra)
- nil manifest-file t))) org-odt-manifest-file-entries)
- (write-region "\n</manifest:manifest>" nil manifest-file t)))
+ (with-current-buffer
+ (find-file-noselect manifest-file t)
+ (insert
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+ <manifest:manifest xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\" manifest:version=\"1.2\">\n")
+ (mapc
+ (lambda (file-entry)
+ (let* ((version (nth 2 file-entry))
+ (extra (if version
+ (format " manifest:version=\"%s\"" version)
+ "")))
+ (insert
+ (format org-odt-manifest-file-entry-tag
+ (nth 0 file-entry) (nth 1 file-entry) extra))))
+ org-odt-manifest-file-entries)
+ (insert "\n</manifest:manifest>"))))
(defun org-odt-update-meta-file (opt-plist)
(let ((date (org-odt-iso-date-from-org-timestamp