Re: Best way to deal with long loops?
From: J French (erewhon_at_nowhere.uk)
Date: 01/15/05
- Next message: Maarten Wiltink: "Re: Here's a "CASE" statement with strings... sorta."
- Previous message: Nicholas Sherlock: "Re: array of TEdit as a constant"
- In reply to: Raptor: "Re: Best way to deal with long loops?"
- Next in thread: Raptor: "Re: Best way to deal with long loops?"
- Reply: Raptor: "Re: Best way to deal with long loops?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 15 Jan 2005 08:50:13 +0000 (UTC)
On Mon, 10 Jan 2005 02:55:16 -0800, "Raptor" <bogus@none.com> wrote:
<snip>
>I'm using a filestream. Now if I could just figure out why
>my file is 2-3X as large... for 50,000 nodes mine is 4.52 MB
>versus the stock routine's 1.82 MB, and they do all the font
>and other stuff as well. Except for the junk blocks, my data
>blocks look a lot like theirs.
Try pumping it out to a TMemoryStream
- use SetSize first to about 5mb
- that should minimize mucking around extending memory
That way you will be able to figure out how much time is wasted on
thousands of disk writes
Note: TFileStream is /not/ buffered
More below
>I'm writing the following record, then the fontname and node
>text:
>
>type
> TNodeSettings = record // R/W for every node.
> nsLevel : integer;
> nsImageIndex : integer;
> nsOverlayIndex : integer;
> nsSelectedIndex : integer;
> nsStateIndex : integer;
> nsChecked : boolean;
> nsExpanded : boolean;
> nsSelected : boolean;
> nsAllowGrayed : boolean;
> nsReadOnly : boolean;
> nsData : pointer;
> nsNodeType : TDCNodeType;
> nsColor : TColor;
> nsState : TCheckBoxState;
> nsFontColor : TColor;
> nsFontStyle : TFontStyles;
>end;
>
>I seem to be writing a bunch of normal-sized blocks, with
>text and fontname and this record taking up about as much
>space as I'd expect, then a long line of apparent trash is
>thrown in. Yet I'm reading it perfectly, with all the node
>attributes working great.
I am not sure about the 'trash'
- my hunch is that it is the 'Inherited' savetostream
- not sure at all
Are you sure that your routine is really like theirs ?
I would have expected them not to store 'default' values
Also :
TNodeSettings = PACKED record
When writing records to file it is a bad idea not to specify 'packed'
as you land up writing filler bytes of garbage between valid record
fields
- a waste of space
- and very confusing when examining the data on disk.
- Next message: Maarten Wiltink: "Re: Here's a "CASE" statement with strings... sorta."
- Previous message: Nicholas Sherlock: "Re: array of TEdit as a constant"
- In reply to: Raptor: "Re: Best way to deal with long loops?"
- Next in thread: Raptor: "Re: Best way to deal with long loops?"
- Reply: Raptor: "Re: Best way to deal with long loops?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|