Is there any way so that Write(Ln) doesn't flush the buffer after each call (as if it's called to write to a file, I knew it from rtl's file handling source), but only when Flush is called? I found some maniac's code that does it at assembler level, but of course it's platform dependant (i386-linux only). Currently, I get it through the use of:
TextRec(<TextVar>).FlushFunc:=nil;
but this forces me to use SysUtils which increase the executable size significantly. If this is the only solution, then please move the record to System unit (if possible, with FileRec too).
Mailing lists / fpc-pascal / 2008-07
Getting fast output
10 messages · 6 people · –
- Lleledumbo 3
- JJonas Maebe 2
- MMarco van de Voort 2
- PPeter Vreman 1
- TTomas Hajny 1
- VVincent Snijders 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Show quoted text 10 lines
http://www.freepascal.org/docs-html/rtl/system/settextbuf.html
Is there any way so that Write(Ln) doesn't flush the buffer after each call (as if it's…
leledumbo wrote 13 lines
The two record types are declared in unit Dos too; with smartlinking, this unit should cause virtually no overhead.
Tomas
http://www.freepascal.org/docs-html/rtl/system/settextbuf.html
Peter Vreman wrote
Oh, yeah! I forgot to mention this. But declaring the buffer will eat spaces ,for instance:
...
var
Buf: array [0..65535] of Byte;...
will add 64k to the executable because it's allocated on the stack.
leledumbo wrote 13 lines
You can also allocate it on the heap.
Jonas
Oh, yeah! I forgot to mention this. But declaring the buffer will eat spaces ,for…
Show quoted text 12 lines
Huh?
A filebuffer variable must be available always, so it is a global variable. Global variables are in the datasegment. The datasegment is traditionally divided into two parts, an initialized part (which goes into the binary) and the uninitialized (which doesn't go in the binary).
Since the above variable is not initialized, it will not go into the binary.
Unless your platform is somehow different, but even then you can allocate it on the heap.
Marco van de Voort wrote 5 lines
I thought the file buffer variable must available for the time a file is opened and can be discarded after the file has been closed.
Vincent
Show quoted text 9 lines
True of course. I tried to paint a general case.
If your filehandling is within one procedure it can be on the stack. If that filehandling is within a class, the buffer can be a member of a class etc.
But in neither of these cases it is in the binary.
You can also allocate it on the heap. Jonas
Jonas Maebe wrote 17 lines
But that won't help you in this case, because settextbuf does not change the flushing behaviour when writing to the screen. For that, you have to follow Tomas' advice.
Jonas
Jonas Maebe-2 wrote 5 lines
Done, but I still demand it to be in System unit. That way, no additional unit is needed. Does Delphi declare TextRec and FileRec anyway?
