Optimize Pos().
Actually, at the time of this comment I had a third patch, so I’ll take the risk to annoy this person for one more time.
Use Index*
in Pos
, instead of manually doing the same. This approach is already used by StrUtils.PosEx
.
For Pos(char, string)
, this is a no-brainer. For Pos(string, string)
, this is not always a good idea (Pos('AB', 'AAA... ×100 As ...AAAB')
will always be slower), but the speedup on good cases is potentially bigger than the slowdown on bad ones, and the latter can be partially addressed by paying more attention to small Count
s in their implementations; in particular, as can be seen from #39996 (closed), REP SCAS
used by IndexWord
and IndexDWord
on i386
can have both unimpressive performance and large startup cost.