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

Re: Large LS_COLORS makes auto_cd very slow



On Apr 9, 10:23am, Václav Zeman wrote:
}
} > I have reimplemented the change using ZSH's own hash table. Please see
} > the attached patch.
} >
} I have put the changes onto github: <git://github.com/wilx/zsh.git>

Unfortunately on some further testing it doesn't quite work properly.

You can't declare

    struct hashnode new_node;

and then call

    addhashnode2(ht, *it, &new_node);

because a pointer to new_node will be placed in the hash table and then
THE CONTENTS OF new_node will be overwritten on the next call to
addhashnode2().  

You have to pass allocated space.  It can be allocated with zhalloc() so
that it needn't be explicitly free()d.

The good news is that fixing this makes completion after "/b" much faster!
The getcoldef() issue that we discussed before turns out to have been
happening because the hash seive was failing to remove all the duplicate
elements, not because of any inherent problem with getcoldef().

I'll commit a repaired version later.

Now the question is at what array length it makes sense to switch from
the simple algorithm to the hash seive.  I suspect Václav's choice of
10 elements may be a little too small given allocation overhead, but I
will leave it that way for the first commit because it's easier to
write the Test/D04parameter.ztst entry for a small number of elements.

-- 
Barton E. Schaefer



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