Subject: Re: Slow highlighting (Re: "drop-in replacement" and transpose-words-match)
From: Bart Schaefer <[email-masked]>
To: Zsh hackers list <[email-masked]>
Date: Fri, 12 Feb 2016 01:41:48 -0800
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Feb 11, 11:43am, Sebastian Gniazdowski wrote:
}
} The point of this tangent example is: every indexing works by
} iterating over buffer and counting characters.

That's only true for indexing from the end of the string (negative indices).
Normal indexing should be direct and very fast.

} By using ":5000" one pass of finding where an index points to is
} skipped, as it says "5000 characters from now on". Index -1 iterates
} from the beginning again to find end of string.

True, but again only relevant if indexing right to left at the end of
a subscript range.

} The only solution is apparently making Zsh storing strings as real
} arrays, of wint_t type.

I'm not sure what kind of arrays you think are "real" as compared to
what zsh uses now, but vast tracts of the shell would have to be
entirely rewritten if we were to change the C string paradigm.

} As for the (i), as far as I remember from the time I worked on C
} source, reverse indexing uses one additional "iterate counting
} characters" block:

IIRC this is unavoidable given that we're counting characters vs.
bytes.  Perhaps that's what you mean by "only solution is wint_t",
but I think that would be discarding a lot of other optimizations.

-- 
Barton E. Schaefer