On Tue, 7 Jun 2005, Peter Vreman wrote:

| > procedure x (const str: string);
| > begin
| >   filewrite (filedescriptor,pchar(str+#13#10)^,length(str)+2);
| > end;
|
| I do not think this should work. You can't pass the address of a temp
| like this.

Yes I had to convert some constants to var's (and initialize them) in one
procedure..
and I noticed Thaddy did this too. I assume delphi is a bit less strict in
that it
let's you get away with the below... but I'm not sure if it's good to be
less strict
in this case.. (poor style?) What do you think..

It is even slow. Splitting it in 2 lines is faster since it removes the
implicit string concattenation

filewrite (filedescriptor,pchar(str)^,length(str));
filewrite (filedescriptor,#13#10,2);

Yes. I would recommend doing it like this; It'll work in Delphi and in
FPC, and is faster in both. For small writes, the difference is not
really harmful, but for a stress-load system (a server log for
example, or a data generator) it's really noticeable. I did some
tests both in Delphi and FPC with this...

Michael.

_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to