From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: struct.el -- a package to encode/decode binary data Date: Thu, 21 Mar 2002 16:56:31 +0200 (IST) Sender: emacs-devel-admin@gnu.org Message-ID: References: <5xbsdigi7n.fsf@kfs2.cua.dk> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: main.gmane.org 1016722847 6633 127.0.0.1 (21 Mar 2002 15:00:47 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 21 Mar 2002 15:00:47 +0000 (UTC) Cc: Richard Stallman , emacs-devel@gnu.org Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16o43a-0001iq-00 for ; Thu, 21 Mar 2002 16:00:46 +0100 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 16o49q-0000Co-00 for ; Thu, 21 Mar 2002 16:07:14 +0100 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16o437-0007SA-00; Thu, 21 Mar 2002 10:00:17 -0500 Original-Received: from is.elta.co.il ([199.203.121.2]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16o41j-0007Nz-00; Thu, 21 Mar 2002 09:58:52 -0500 Original-Received: from is (is [199.203.121.2]) by is.elta.co.il (8.9.3/8.8.8) with SMTP id QAA11343; Thu, 21 Mar 2002 16:56:31 +0200 (IST) X-Sender: eliz@is Original-To: "Kim F. Storm" In-Reply-To: <5xbsdigi7n.fsf@kfs2.cua.dk> Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.5 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:2096 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:2096 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. _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel