Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Option reorganisation, Part IV.

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.


Messages sorted by: Reverse Date, Date, Thread, Author