The mapping between byte positions and segments is very slow, it may happen that some thousands segments have to be processed (sometimes more than 6000 when testing with application Scidb). The revised version is using a section structure for such searches, the increase in speed is about 40x (even more, because the double linked list provides more improvements). The management of the section chain requires additional code, but here the runtime is constant, contrary to the non-constant (linear) search time.
The gain in speed is huge if long lines with many marks and hyphens are involved. This is the first step to solve the long line problem. Although the impact of this step is only minor, it is already significant.
Moreover with the support for hyphenated text it is expected that the number of segments will be high, this means that without this acceleration the hyphenation support will slow down the text widget significantly.
Another peformance issue is the repeated mapping between byte positions and segments. I've overworked the index class (struct tkTextIndex) and the tkTextIndex* functions, now the segment will be cached, this avoids the repeated mapping in most cases. Only in a few cases a repeated mapping cannot be avoided, because it may happen that a segment will expire due to changes in the segment chain of a line. The tkTextIndex* functions are detecting this case automatically.