Re: Help reading structured binary files
- From: "alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx>
- Date: 21 Jul 2005 13:27:48 -0700
I'd certainly agree with J.French's suggestion to read it from a file
into a memory stream in one chunk. But also I'd read it from there into
another memory stream which would (in the end) be your
concatenated string contents. In copying from the first MS to the total
MS I'd change the string length from a length byte to a '=' value ($3D
== 61d), having previously read the length to know how many bytes to
copy. The second memory stream should be allocated a large Capacity to
start with.
While you're doing the MS to MS copying you keep a note of MS2 position
(== final length at end).
_Then_ allocate a string of that length and copy the MS2 into it once
and for all. Allocating a string and concatenating it for each element
of each file is sssslllloooowwww (two memory allocations per element).
I reckon doing it the above way, while slightly more code, would be
much much quicker.
Always try and reduce the number of string memory allocations in any
algorithm.
Alan Lloyd
.
- References:
- Help reading structured binary files
- From: Robert Kilroy
- Re: Help reading structured binary files
- From: Bruce Roberts
- Re: Help reading structured binary files
- From: Robert Kilroy
- Re: Help reading structured binary files
- From: J French
- Re: Help reading structured binary files
- From: Robert Kilroy
- Re: Help reading structured binary files
- From: J French
- Help reading structured binary files
- Prev by Date: Re: Delphi 7 & Delphi 2005 on same pc ?
- Next by Date: OpenPictureDialog Problems
- Previous by thread: Re: Help reading structured binary files
- Next by thread: Re: Convert C-Builder program to Delphi?
- Index(es):
Relevant Pages
|