On 9/17/13, Mark Morgan Lloyd <markmll.laza...@telemetry.co.uk> wrote: > Hans-Peter Diettrich wrote:
HPD code 3: begin Result := AUtf8Char; SetLength(Result, nb); PC := PChar(Result); for i:=1 to nb - UCharLen do begin PC[UCharLen] := PC[0]; //very nice b.t.w. inc(PC); end; end; My code 3: begin SetLength(Result, 3 * N); C1 := AUtf8Char[1]; C2 := AUtf8Char[2]; C3 := AUtf8Char[3]; PC := PChar(Result); for i:=1 to N do begin PC^ := C1; inc(PC); PC^ := C2; inc(PC); PC^ := C3; inc(PC); end; end; I tested that for speed, and though they consistently differ about 2-6%, on further inspection this is dependant on the order the 2 are executed: the first one is always the slower... So, I conclude they perform roughly the same. Bart -- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus