emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ANN] faster org-table-to-lisp


From: Nicolas Goaziou
Subject: Re: [ANN] faster org-table-to-lisp
Date: Fri, 01 May 2020 00:35:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

tbanelwebmin <address@hidden> writes:

> I found a way to ensure full backward compatibility. I keep the same
> signature. When a table is given as a string parameter, it is inserted
> into a temporary buffer, which is then parsed. Overall, the resulting
> speed is quite satisfactory.

Awwww, you didn't like my ELEMENT suggestion.

> I also made the function more tolerant to ill-formed tables: missing
> "|" or excess of spaces at the end of a row are now gracefully
> accepted.

Great!

>             (while (not (re-search-forward "\\=\\s-*\n" end t))

(re-search-forward "\\=..." ...) -> (looking-at "..." ...)

Note that Org does not use \\s- but the simpler [ \t].

Also, the regexp assumes the table end with a newline character, which
may not be the case.

>               (unless (re-search-forward "\\=\\s-*\\([^|\n]*\\)\\(|?\\)" end 
> t)
>                 (user-error "Malformed table at char %s" (point)))

This cannot happen. The regexp above matches anything, i.e., the empty
string.

>               (goto-char (match-end 1))
>               (skip-chars-backward " \t" (match-beginning 1))
>               (push
>                (buffer-substring-no-properties (match-beginning 1) (point))
>                row)
>               (goto-char (match-end 2)))
>             (push (nreverse row) table)))
>         (nreverse table)))))

I applied your suggestion, with a few simplifications. Hopefully, it
squeezed a bit more the execution time. Let me know!

> The new implementation can be more than 100 times faster. This enhances
> responsiveness of Babel or Gnuplot blocks handling thousands long
> tables.

Looks good. However, we didn't change the signature, so I didn't add
this to ORG-NEWS. It is in the commit message, tho.

Thank you!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]