help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: [External] : Passing buffers to function in elisp


From: tomas
Subject: Re: [External] : Passing buffers to function in elisp
Date: Wed, 22 Feb 2023 06:35:07 +0100

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: signature.asc
Description: PGP signature


reply via email to

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