Well, the first one will certainly be faster. The solution to a hard-coded, very specific problem almost always goes much faster than transferring a specific solution to the overall problem of the solution. As for โsignificantlyโ faster, why don't you check it out? Run both versions in a loop 10 million times and use TStopwatch (or something else if you don't have D2010 or newer) to have this time.
One more thing: the first is certainly faster, but it may be wrong. If length(TestString) not guaranteed to be> = 2, there may be an error condition. If TestString is an empty string, this will throw an exception. If not, you may or may not get an exception depending on the compiler settings.
source share