From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] trunk r115095: Simplify, port and tune bool vector implementation. Date: Mon, 18 Nov 2013 10:45:55 -0800 Organization: UCLA Computer Science Department Message-ID: <528A6063.3080609@cs.ucla.edu> References: <5288B15F.8060102@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1384800382 4403 80.91.229.3 (18 Nov 2013 18:46:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Nov 2013 18:46:22 +0000 (UTC) To: Daniel Colascione , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 18 19:46:26 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ViTq4-0005Wb-Cn for ged-emacs-devel@m.gmane.org; Mon, 18 Nov 2013 19:46:24 +0100 Original-Received: from localhost ([::1]:45440 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViTq4-0001Mm-1S for ged-emacs-devel@m.gmane.org; Mon, 18 Nov 2013 13:46:24 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViTpv-0001G9-8U for emacs-devel@gnu.org; Mon, 18 Nov 2013 13:46:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ViTpn-0007fO-GN for emacs-devel@gnu.org; Mon, 18 Nov 2013 13:46:15 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:51392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViTpn-0007dy-Ag for emacs-devel@gnu.org; Mon, 18 Nov 2013 13:46:07 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id E11D839E8100; Mon, 18 Nov 2013 10:45:59 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EEWgiN2sb0XX; Mon, 18 Nov 2013 10:45:59 -0800 (PST) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 6631C39E80F8; Mon, 18 Nov 2013 10:45:59 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 In-Reply-To: <5288B15F.8060102@dancol.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 131.179.128.62 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:165335 Archived-At: On 11/17/2013 04:06 AM, Daniel Colascione wrote: > Can you comment the line you added, though? Done, in trunk bzr 115139. > Zero-length bool vectors are _extremely_ uncommon. Please don't > reduce efficiency in the general case. Surely any efficiency differences are insignificant here, and it may well be worth keeping the code simple. However, it's not that big a deal either way so I changed it back in trunk bzr 115139. > - changed |= adata[i] ^ mword; > + if (! changed) > + changed = adata[i] != mword; > > That's not an optimization. It was part of an optimization overall, as the surrounding code was changed to avoid initializing a newly-created bool vector to zeros when it was going to be immediately overwritten with data, and the above change was needed to avoid accessing possibly-uninitialized data. The point is moot now, though, after trunk bzr 115139, where I optimized away 'changed' entirely. > We will never run on machines where sizeof(char) == sizeof(int). True for Emacs's current targets, but when it's easy to write code portable to those machines (which do exist), we might as well do so, if only to document what's going on -- sort of the same reason that we write CHAR_BIT rather than 8.