emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: tbanelwebmin <tbanelwebmin@free.fr>
Cc: emacs-orgmode@gnu.org
Subject: Re: [ANN] faster org-table-to-lisp
Date: Fri, 01 May 2020 00:35:25 +0200	[thread overview]
Message-ID: <878sica9g2.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <0166c38e-e1f2-9cbc-4cf8-1b287600368d@free.fr> (tbanelwebmin@free.fr's message of "Thu, 30 Apr 2020 22:28:58 +0200")

tbanelwebmin <tbanelwebmin@free.fr> 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!


  parent reply	other threads:[~2020-04-30 22:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-30  6:34 [ANN] faster org-table-to-lisp tbanelwebmin
2020-04-30  8:09 ` Nicolas Goaziou
2020-04-30 20:28   ` tbanelwebmin
2020-04-30 20:47     ` Daniele Nicolodi
2020-04-30 21:01       ` tbanelwebmin
2020-04-30 22:35     ` Nicolas Goaziou [this message]
2020-05-01  6:35       ` tbanelwebmin
2020-05-01 10:15         ` Nicolas Goaziou
2020-05-01 12:41           ` tbanelwebmin
2020-05-01 13:11             ` Nicolas Goaziou
2020-05-02  7:41               ` tbanelwebmin
2020-05-02  9:35                 ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878sica9g2.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=tbanelwebmin@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).