> 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. > > The expensive bit is that _comp_colors is declared as a unique array, > so every time it gets rebuilt the resulting 1700+ entries are all > compared against one another to make sure there is no duplication. > Repeat that nine times and it takes a while. 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? 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? - V