From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Banel Subject: spee-up table refresh Date: Sun, 08 Jan 2017 18:28:27 +0100 Message-ID: <587276BB.9000008@free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQHGo-00038p-8l for emacs-orgmode@gnu.org; Sun, 08 Jan 2017 12:28:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQHGl-0002dx-1S for emacs-orgmode@gnu.org; Sun, 08 Jan 2017 12:28:38 -0500 Received: from smtp3-g21.free.fr ([212.27.42.3]:10408) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cQHGk-0002V3-P0 for emacs-orgmode@gnu.org; Sun, 08 Jan 2017 12:28:34 -0500 Received: from [IPv6:2a01:e35:2e21:def0:21bc:a51c:900e:b555] (unknown [IPv6:2a01:e35:2e21:def0:21bc:a51c:900e:b555]) by smtp3-g21.free.fr (Postfix) with ESMTP id 037C113F892 for ; Sun, 8 Jan 2017 18:28:27 +0100 (CET) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Re-computing a large table is slow. Hereafter is a test case for a 1000 row table. My computer refreshes it in 44 seconds. Here is a fast-and-dirty-not-to-be-commited patch which speed-up the refresh to less than 1 second. I just removed the last 3 lines of (org-at-table-p). I don't understand those 3 lines, but everything still works fine without them (the 688 tests work as expected). Those lines indirectly call (org-element--cache-put) a quadratic number of times. For a 1000 rows table this is 501500 times (about 1000x1000/2 times). #+BEGIN_SRC elisp :results none (defun org-at-table-p (&optional table-type) "Non-nil if the cursor is inside an Org table. If TABLE-TYPE is non-nil, also check for table.el-type tables. If `org-enable-table-editor' is nil, return nil unconditionally." (and org-enable-table-editor (save-excursion (beginning-of-line) (looking-at-p (if table-type "[ \t]*[|+]" "[ \t]*|"))) )) ; (or (not (derived-mode-p 'org-mode)) ; (let ((e (org-element-lineage (org-element-at-point) '(table) t))) ; (and e (or table-type (eq (org-element-property :type e) 'org))))))) #+END_SRC Here is a test case. 1- First create a 1000 row table: #+BEGIN_SRC elisp :results none (goto-char (point-max)) (let ((i 1000)) (while (> i 0) (insert (format "| %4s | |\n" i)) (setq i (1- i)))) (insert "#+TBLFM: $2=$1*10\n") #+END_SRC 2- Then, with point in the table, type C-u C-c * Regards, Thierry