From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11922 invoked from network); 1 Jan 1997 20:15:29 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 1 Jan 1997 20:15:29 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id PAA18203; Wed, 1 Jan 1997 15:19:44 -0500 (EST) Resent-Date: Wed, 1 Jan 1997 15:19:44 -0500 (EST) From: Zoltan Hidvegi Message-Id: <199701011757.SAA00867@hzoli.ppp.cs.elte.hu> Subject: Re: Option reorganisation, Part IV. To: zefram@dcs.warwick.ac.uk (Zefram) Date: Wed, 1 Jan 1997 18:57:43 +0100 (MET) Cc: zefram@dcs.warwick.ac.uk, zsh-workers@math.gatech.edu In-Reply-To: <28714.199612311227@stone.dcs.warwick.ac.uk> from Zefram at "Dec 31, 96 12:27:44 pm" X-Mailer: ELM [version 2.4ME+ PL17 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"KmT49.0.JS4.WRioo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2691 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Zefram wrote: > The point of a hashtable is to make name lookups very quick. All right. Show me any scipt which runs measurably slower after my patch, and I'll restore using the array. > scanhashtable() is used when it is necessary to look at all elements in > a hash table; in this case it is not necessary, as there is another, > easier, way to look at all the options. And, of course, going through Yes, there is but theoretically it is cleaner to use hashtable functions only. And just to show how much more complicated the hash-scan code: for (i = 0; i < ht->hsize; i++) for (hn = ht->nodes[i]; hn; hn = hn->next) if (!(hn->flags & flags2)) scanfunc(hn, scanflags); The if condition skipps four option aliases. The overhead is this four skipped options (from 108), and for each option one pointer dereference and assignment, two conditional jump and a function call/return. At worst this means a few dozen machine cycles. With setopt without arguments which prints all options, there is the overhead to sort the options but that's again unnoticable in interactive usage and setopt without arguments is used very rarely in scripts. > >Yes but again you do not win much here. I could store numbers for aliases > >but that without optno -> name reverse lookup I'll not be able to print > >these aliases. > > I don't see what you mean here. The option aliases should never be > output; they're just extra names that can be used when specifying > options. All that is needed of an option alias is a mapping from name > to number, and putting the number directly in the hash table element > achieves this with the minimum of fuss. There is simply no need to map > from alias name to canonical name. I just thought that a form of setopt to print option aliases would be nice. But I really do not think that necessary and I'll gladly remove textual aliases together with this union hack. Zoltan