On 25-12-20 08:28, Ihor Radchenko wrote:
"John Wiegley" <[email protected]> writes:
Are there any org-table.el masters who might be interested in helping
with such a reworking of the calculation engine?
It has been a while. I am wondering if you are still interested in this.
Rewriting org-table.el is daunting.
I did some optimizations by looking at hot-spots and bugs. This is a
much less ambitious work than the one envisioned by John. But the gains
are still worthwhile. For instance, I published this function:
(defun orgtbl-aggregate--recalculate-fast ()
"Wrapper around `org-table-recalculate'.
The standard `org-table-recalculate' function is slow because
it must handle lots of cases. Here the table is freshly created,
therefore a lot of special handling and cache updates can be
safely bypassed. Moreover, the alignment of the resulting table
is delegated to orgtbl-aggregate, which is fast.
The result is a speedup up to x6, and a memory consumption
divided by up to 5. It makes a difference for large tables."
(let ((old (symbol-function 'org-table-goto-column)))
(cl-letf (((symbol-function 'org-fold-core--fix-folded-region)
(lambda (_a _b _c)))
((symbol-function 'jit-lock-after-change)
(lambda (_a _b _c)))
;; Warning: this org-table-goto-column trick fixes a bug
;; in org-table.el around line 3084, when computing
;; column-count. The bug prevents single-cell formulas
;; creating the cell in some rare cases.
((symbol-function 'org-table-goto-column)
(lambda (n &optional on-delim _force)
;; △
;;╭───────────────────────────╯
;;╰╴parameter is forcibly changed to t╶─╮
;; ╭───────────────╯
;; ▽
(funcall old n on-delim t))))
(condition-case nil
(org-table-recalculate t t)
;; △ △
;; for all lines╶────────╯ │
;; do not re-align╶────────╯
(args-out-of-range nil)))))
This self contained function can be found here:
https://github.com/tbanel/orgaggregate/blob/master/orgtbl-aggregate.el