From: Stephen Leake <stephen_leake@stephe-leake.org>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Re: access to raw buffer text from module
Date: Thu, 05 Dec 2019 17:01:41 -0800 [thread overview]
Message-ID: <86zhg6mfm2.fsf_-_@stephe-leake.org> (raw)
In-Reply-To: <jwva7866fac.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 05 Dec 2019 09:11:11 -0500")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> A related but different question. Would it be possible to get access to
>> the raw buffer data from dynamic modules? (That is, pointer to the start,
>> length and gap information.)
>
> You might like to talk with Stephen Leake
> <stephen_leake@stephe-leake.org>.
> IIUC he wrote a dynamic module which parses the buffer. AFAICT he
> didn't use such a "raw" access, so it'd be interesting to hear about
> his experience.
No, I sent the buffer content as a string.
I was hoping to avoid that copy, but other things turned out to be way
slower (creating _lots_ of text properties), so I went back to a
separate process, and made that faster (doing more stuff in the process,
so fewer text properties are needed).
>> I'm only interested in read-only access, and I'd be happy to patch it
>> in myself if it's deemed generally acceptable.
>
> It would tend to expose internal data subject to change (and offer the
> ability to change this data in a way that can break some invariants), so
> it's definitely not in the style of the current module interface.
>
> But we may be able to provide a slightly less "raw" access that doesn't
> suffer in the same way. So details about your particular needs would be
> helpful to try and figure out what we can do (i.e. tell us the problems
> you face when using `char-after` or `buffer-substring`, which would be
> the main ways I can think of to access the buffer's content with the
> current module API).
In my case, I wanted raw speed when lexing the source text. The lexer
I'm using can handle utf-8, when given a start address and byte length.
Allowing for a gap would mean checking for that at each byte, which
might slow things down as much as copying.
But lexing is a _very_ small portion of the total parse time, so it's
really not worth worrying about the copy either; even sending the text
to a separate process does not take a noticeable amount of time.
If I convert to LSP style (https://langserver.org/), then the full text
is sent once, and only edits are sent after that, making the copy issue
irrelevant.
--
-- Stephe
next prev parent reply other threads:[~2019-12-06 1:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-03 20:28 Drawing to cairo context from within emacs module? David Engster
2019-12-05 4:42 ` Richard Stallman
2019-12-05 5:35 ` Eli Zaretskii
2019-12-05 9:02 ` Pankaj Jangid
2019-12-06 4:12 ` Richard Stallman
2019-12-05 13:42 ` Eivind Fonn
2019-12-05 14:11 ` Stefan Monnier
2019-12-06 1:01 ` Stephen Leake [this message]
2019-12-05 15:08 ` Eli Zaretskii
[not found] ` <CAKNFwoQLZpykNFnG9C4WZ12BR45pn-40kykar09UezHFm2U2jw@mail.gmail.com>
2019-12-06 14:55 ` Eli Zaretskii
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.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86zhg6mfm2.fsf_-_@stephe-leake.org \
--to=stephen_leake@stephe-leake.org \
--cc=emacs-devel@gnu.org \
/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.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).