You are not logged in.
Pages: 1
I've already addressed this naming in another thread, and I seem to recall that you wanted to consider it more often in the future. Avoid negations in variable names. At these points in the source code I always have to stop and think twice if I have understood it correctly. And now I read:
constructor TTextWriter.CreateOwnedStream(aBuf: pointer; aBufSize: integer; NoSharedStream: boolean);
begin
if (not NoSharedStream) and TextWriterSharedStreamSafe.TryLock then
fStream := TextWriterSharedStream
Why not write better without rethinking:
constructor TTextWriter.CreateOwnedStream(aBuf: pointer; aBufSize: integer; UseSharedStream: boolean);
begin
if UseSharedStream and TextWriterSharedStreamSafe.TryLock then
fStream := TextWriterSharedStream
With best regards
Thomas
Offline
It is a biais I have indeed. I suppose it comes from the asm the compiler generates in such case.
A default value to false is shorter in asm than a default value to true.
For false, you store zero in a register, which is just a xor on self register on Intel/AMD, or you use the Zero register on ARM.
I guess it does not make any difference here, because this parameter is mainly for internal use.
Almost no "normal" user would change the default value
Offline
Pages: 1