Optimize Pos().
Actually, at the time of [this comment](https://gitlab.com/freepascal.org/fpc/source/-/issues/40070#note_1224480152) 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, `REP SCAS` used by `IndexWord` and `IndexDWord` on `i386` can have both unimpressive performance and large startup cost. [pos-index.patch](/uploads/2c336932d0bc87540179f36207af400a/pos-index.patch)
issue