[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: struct.el -- a package to encode/decode binary data
From: |
Eli Zaretskii |
Subject: |
Re: struct.el -- a package to encode/decode binary data |
Date: |
Thu, 21 Mar 2002 16:56:31 +0200 (IST) |
On 21 Mar 2002, Kim F. Storm wrote:
> > > Is there some specific reason not to use unibyte strings here?
> >
> > They are simply not needed here (AFAICS).
>
> On the surface, it looks "obvious" to use unibyte strings for
> data which is known to be - and processed as - byte-oriented
> data.
That's the C programmer in you trying to get free ;-)
Seriously, though: I think we should stop thinking about unibyte vs
multibyte strings, and instead think about them as, well, just strings.
The uni- vs multi-byteness is an implementation detail that should not
bother a Lisp programmer. (That it sometimes does is a sign of bugs
that need to be fixed, IMHO.)
Emacs 21 is perfectly capable of holding binary data in a multibyte
buffer, so there's no need to do this on the Lisp level. If Emacs
decides that a buffer needs to be switched to unibyte mode, it will do
so automatically.
> > IMO, unibyte strings
> > should not be used unless absolutely necessary, ideally never.
>
> Am I right in assuming that aref, aset, and substring are potentially
> much slower on a multibyte string than on a unibyte string?
If the string holds non-ASCII text, yes. But not in your case, where the
``string'' holds binary data, I think.
Also, I think the slow-down should be noticeable when you need to walk
many characters, like when you invoke substring with a large argument.
In your case, you take a small number of characters and then run some
Lisp on them (e.g. to convert them into a number), so I think the
slow-down will be negligible. But that's speculation: I didn't really do
any measurements, so some complication might be evading me.
- Re[3]: struct.el -- a package to encode/decode binary data, (continued)
- Re: struct.el -- a package to encode/decode binary data, Eli Zaretskii, 2002/03/19
- Re: struct.el -- a package to encode/decode binary data, Luke Gorrie, 2002/03/19
- Re: struct.el -- a package to encode/decode binary data, Kim F. Storm, 2002/03/19
- Re: struct.el -- a package to encode/decode binary data, Thien-Thi Nguyen, 2002/03/19
- Re: struct.el -- a package to encode/decode binary data, Richard Stallman, 2002/03/21
- Re: struct.el -- a package to encode/decode binary data, Eli Zaretskii, 2002/03/21
- Re: struct.el -- a package to encode/decode binary data, Kim F. Storm, 2002/03/21
- Re: struct.el -- a package to encode/decode binary data,
Eli Zaretskii <=
- Re: struct.el -- a package to encode/decode binary data, Kim F. Storm, 2002/03/21
- Re: struct.el -- a package to encode/decode binary data, Stefan Monnier, 2002/03/21
- Re: struct.el -- a package to encode/decode binary data, Eli Zaretskii, 2002/03/21
- Re: struct.el -- a package to encode/decode binary data, Stefan Monnier, 2002/03/21
- Re: struct.el -- a package to encode/decode binary data, Eli Zaretskii, 2002/03/22
- Re: struct.el -- a package to encode/decode binary data, Miles Bader, 2002/03/21
- Re: struct.el -- a package to encode/decode binary data, Richard Stallman, 2002/03/22
- Re: struct.el -- a package to encode/decode binary data, Stefan Monnier, 2002/03/21
- Re: struct.el -- a package to encode/decode binary data, Richard Stallman, 2002/03/22
Re: struct.el -- a package to encode/decode binary data, Kenichi Handa, 2002/03/21