Re: memorymanager/fastmm question/suggestion
- From: "Avatar Zondertau" <avatarzt@xxxxxxxxx (please reply to newsgroup)>
- Date: 29 Oct 2005 11:09:42 -0700
> would it make sense to have a FastSetLength(str,length,blocksize)
> function, where blocksize is a 'hint' to fastmm for the blocksize to
> allocate/reserve.
>
> the intent is, in a situation where you know you'll be appending data
> to a string up to a particular size, you could reserve enough space
> so as the string increases in length, it becomes an in-place realloc,
> instead of a possible move..
>
> eg
>
> FastSetLength(s,0,10000);
> //now length(s)=0, but its actually has a 10k block of memory
> available. //append data to the string. there should be no move.
> for i:=1 to 9000 do s:=s+'x';
>
> if you know what i mean..
> if it needs more space, it would then be a normal move/realloc as
> required.
>
> thoughts? would it be worthwhile?
This can be written efficiently like this:
SetLength(S, 10000);
for I := 1 to 9000 do
S[I] := 'x';
SetLength(S, 9000); // In more realistic cases count the number of
// characters while you add them
There's no need to make a new FastSetLength function for this.
.
- References:
- memorymanager/fastmm question/suggestion
- From: Ben Taylor [Team Indy]
- memorymanager/fastmm question/suggestion
- Prev by Date: Re: Status of Direct Calling Libraries
- Next by Date: Re: result double
- Previous by thread: Re: memorymanager/fastmm question/suggestion
- Next by thread: Re: memorymanager/fastmm question/suggestion
- Index(es):
Relevant Pages
|