I need to know if all characters in a string are equal (formed by the same character). the function must return true or false depending if all the elements of the string ar
You could consider creating an Integer
value with the Element
repeated 4 times (since this is AnsiChar
in Delphi 7), shifted like Ord(Element) + Ord(Element) shl 8 + Ord(Element) shl 16 + Ord(Element) shl 24
, then typecast the string to a PIntegerArray
(^array[0..MaxInt div 4 - 1] of Integer
) and loop over it Length(Str) div 4
times, comparing as integers instead of characters. You'll need to compare the last few Length(str) mod 4
characters manually though.