zsh-workers
 help / color / mirror / code / Atom feed
From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: zefram@dcs.warwick.ac.uk (Zefram)
Cc: zefram@dcs.warwick.ac.uk, zsh-workers@math.gatech.edu
Subject: Re: Option reorganisation, Part IV.
Date: Wed, 1 Jan 1997 18:57:43 +0100 (MET)	[thread overview]
Message-ID: <199701011757.SAA00867@hzoli.ppp.cs.elte.hu> (raw)
In-Reply-To: <28714.199612311227@stone.dcs.warwick.ac.uk> from Zefram at "Dec 31, 96 12:27:44 pm"

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


      reply	other threads:[~1997-01-01 20:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-27 23:02 Zoltan Hidvegi
1996-12-30 10:33 ` Zefram
1996-12-30 15:53   ` Zoltan Hidvegi
1996-12-31 12:27     ` Zefram
1997-01-01 17:57       ` Zoltan Hidvegi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199701011757.SAA00867@hzoli.ppp.cs.elte.hu \
    --to=hzoli@cs.elte.hu \
    --cc=zefram@dcs.warwick.ac.uk \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).