[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [External] : Passing buffers to function in elisp
From: |
Michael Heerdegen |
Subject: |
Re: [External] : Passing buffers to function in elisp |
Date: |
Sat, 25 Feb 2023 12:23:22 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Petteri Hintsanen <petterih@iki.fi> writes:
> (defun emms-info-native--read-and-decode-ogg-page (filename offset)
> (with-temp-buffer
> (set-buffer-multibyte nil)
> (insert-file-contents-literally filename
> nil
> offset
> (+ offset
> emms-info-native--ogg-page-size))
> (emms-info-native--decode-ogg-page (buffer-string))))
> [...]
>
> (defun emms-info-native--decode-ogg-packets (filename packets)
> (let ((num-packets 0)
> (offset 0)
> (stream (vector)))
> (while (< num-packets packets)
> (let ((page (emms-info-native--read-and-decode-ogg-page filename
> offset)))
> (cl-incf num-packets (or (plist-get page :num-packets) 0))
> (cl-incf offset (plist-get page :num-bytes))
> (setq stream (vconcat stream (plist-get page :stream)))
> stream))
If `emms-info-native--read-and-decode-ogg-page' is called very often
(hundreds of times or more), it's probably better to use one single
buffer instead of a fresh temp buffer every single time. Using temp
buffers creates quite a bunch of garbage IME.
Michael.
- Passing buffers to function in elisp, Petteri Hintsanen, 2023/02/21
- RE: [External] : Passing buffers to function in elisp, Drew Adams, 2023/02/21
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/22
- Re: [External] : Passing buffers to function in elisp, Petteri Hintsanen, 2023/02/24
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/25
- Re: [External] : Passing buffers to function in elisp,
Michael Heerdegen <=
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, Michael Heerdegen, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, Stefan Monnier, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, Petteri Hintsanen, 2023/02/27
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/28
Re: Passing buffers to function in elisp, tomas, 2023/02/22