[fpc-devel] copy for PChar

Mattias Gaertner nc-gaertnma at netcologne.de
Sun Feb 19 17:34:20 CET 2012


On Sun, 19 Feb 2012 20:01:11 +0400
Sergei Gorelkin <sergei_gorelkin at mail.ru> wrote:

> 19.02.2012 18:38, Mattias Gaertner пишет:
> > Hi,
> >
> > When I use "copy" on a PChar (e.g. copy(p,1,1)), it is very slow,
> > because the compiler converts the PChar to a string.
> >
> Not sure why it is allowed in the first place. 

It's a useful feature.

> If out of Delphi compatibility, maybe we should leave 
> it enabled for {$mode delphi} only (should be possible because copy is partially handled by compiler).
> 
> > Is there already a function for PChar?
> >
> > Can an overloaded version of copy be added?
> >
> It is a question how to interpret indices then (PChar is zero-based while strings are 1-based).
> And actually it will mean 4 overloads: PChar, PWideChar, array of char, array of widechar.

Indeed. That would be confusing.

Is there already a function

function Copy(StartPos: PChar; Count: PtrUInt; StopAt0: boolean =
true): string;


Mattias



More information about the fpc-devel mailing list