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

Re: Large LS_COLORS makes auto_cd very slow



On Apr 6,  8:30pm, Valodim Skywalker wrote:
} 
} > For each of these categories, _setup line 12 rebuilds the value of
} > the _comp_colors array to add new patterns such that any pattern that
} > started with '=' gets copied with a prefix matching the tag currently
} > being tested; e.g. '(commands)=...' or '(jobs)=...'
} > 
} > This is done even for tags that won't have any matches because the
} > colors array has to be ready for the internals to use when a match is
} > found, there's no way to "call back" to build it on demand.
} 
} Are these steps all hard requirements? I don't have a good overview of
} things, but some of these parts seem like they could be rethought to
} work faster or the cpu/memory tradeoff shifted a bit towards more memory
} use or something. Does the array really need to be unique?

Using the hash seive for arrayuniq seems to resolve that part of the
problem.  The array doesn't have to be unique, but making it not so will
only make the other part of the problem [getcoldef()] worse.

} How much fluctuation is in these contexts, this is a frequent
} operation so maybe caching the entries, possibly only for known often
} called contexts, could help?

It's conceivable that getcoldef() could use a cache.  The parse of each
string passed to getcoldef() is not dependent on context, although the
strings themselves are, so getcoldef() could just stash away every one
it ever sees and return it the next time the same parse is needed.

All the heap allocations [zhalloc()] in getcoldef() would have to become
global allocations [zcalloc()], patcompile() would need to be called
with the PAT_ZDUP flag, and the module boot_() and cleanup_() routines
would then allocate and delete a hash table for the cache.

However, this would only help on second and subsequent completions in
a context that had been completed before.  E.g., the first completion
after "/b" in command position would still have a noticable delay; it
checks at least eight different contexts.



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