From: <tomas@tuxteam.de>
To: help-gnu-emacs@gnu.org
Subject: Re: [External] : Passing buffers to function in elisp
Date: Wed, 22 Feb 2023 06:35:07 +0100 [thread overview]
Message-ID: <Y/Wpi2eiHDVzLdcZ@tuxteam.de> (raw)
In-Reply-To: <SJ0PR10MB5488EF2340D14D9183A0ABE9F3A59@SJ0PR10MB5488.namprd10.prod.outlook.com>
[-- Attachment #1: Type: text/plain, Size: 916 bytes --]
On Tue, Feb 21, 2023 at 11:21:47PM +0000, Drew Adams wrote:
> > I'm reading some bytes into a temp buffer, like so:
> >
> > (with-temp-buffer
> > (set-buffer-multibyte nil)
> > (insert-file-contents-literally filename nil 0 64000))
> >
> > then I pass these bytes to functions for processing, like this
> >
> > (func1 (buffer-string))
> >
> > or sometimes just part of them
> >
> > (func2 (substring (buffer-string) 100 200))
>
> Why aren't you passing the buffer itself to func1?
> Why aren't you passing the buffer itself and the limits 100 and 200 to func2?
>
> What is it that you're really trying to do?
That's exactly the point, yes.
> Yes, if you start manipulating strings instead of buffer text you will pay a performance penalty, in general.
...the question being whether it's worth it or not.
Sometimes it is, sometimes it isn't :-)
Cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2023-02-22 5:35 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-21 21:18 Passing buffers to function in elisp Petteri Hintsanen
2023-02-21 23:21 ` [External] : " Drew Adams
2023-02-22 5:35 ` tomas [this message]
2023-02-24 20:08 ` Petteri Hintsanen
2023-02-25 6:40 ` tomas
2023-02-25 11:23 ` Michael Heerdegen
2023-02-25 13:45 ` tomas
2023-02-25 18:31 ` Michael Heerdegen
2023-02-25 19:05 ` tomas
2023-02-25 23:52 ` Stefan Monnier via Users list for the GNU Emacs text editor
2023-02-27 20:44 ` Petteri Hintsanen
2023-02-28 5:37 ` tomas
2023-03-03 15:19 ` Stefan Monnier via Users list for the GNU Emacs text editor
2023-03-07 21:48 ` Petteri Hintsanen
2023-03-07 22:45 ` Stefan Monnier
2023-03-08 5:38 ` tomas
2023-09-06 19:05 ` Petteri Hintsanen
2023-09-06 21:12 ` Stefan Monnier
2023-02-22 5:30 ` tomas
2023-02-23 9:34 ` Michael Heerdegen
2023-02-23 9:51 ` tomas
2023-02-23 16:19 ` Marcin Borkowski
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y/Wpi2eiHDVzLdcZ@tuxteam.de \
--to=tomas@tuxteam.de \
--cc=help-gnu-emacs@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.