emacs-devel
[Top][All Lists]
Advanced

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

Re: Towards a cleaner build: bindat


From: Eli Zaretskii
Subject: Re: Towards a cleaner build: bindat
Date: Sat, 15 Jun 2019 17:22:30 +0300

> From: Lars Ingebrigtsen <address@hidden>
> Date: Sat, 15 Jun 2019 16:04:08 +0200
> 
>    ((eq type 'str)
>     (let ((s (substring bindat-raw bindat-idx (+ bindat-idx len))))
>       (setq bindat-idx (+ bindat-idx len))
>       (if (stringp s) s
>       (string-make-unibyte (concat s)))))
>    ((eq type 'strz)
>     (let ((i 0) s)
>       (while (and (< i len) (/= (aref bindat-raw (+ bindat-idx i)) 0))
>       (setq i (1+ i)))
>       (setq s (substring bindat-raw bindat-idx (+ bindat-idx i)))
>       (setq bindat-idx (+ bindat-idx len))
>       (if (stringp s) s
>       (string-make-unibyte (concat s)))))
> 
> s is either a string or a vector, and if it's a vector, we transform it
> to a unibyte string by running it through concat and
> string-make-unibyte.
> 
> But as far as I can tell from poking at the code, the vector will always
> be a vector of byte values; i.e., in the 0-255 region.  concat, indeed,
> returns a multibyte string:
> 
> (multibyte-string-p (concat [250 255]))
> => t
> 
> So if we just avoid the concat and make a unibyte string from the vector
> in, well, just about any other way, then the string-make-unibyte
> should be unnecessary, right?

Yes.  You should create the string by calling unibyte-string.



reply via email to

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