From: Tom Benson <[EMAIL PROTECTED]>
Date: Mon, 12 Feb 2007 17:09:17 +1100
RB strings are not mutable...
When you call " s = s + str(i) " a new string is created in memory,
the value of the old string plus the new string are added together an
placed in the new string, and then the old string is taken out of
memory.
Each iteration of this loop will therefore be a little longer than
the last, as the string slowly winds it's way up to 50,000 characters
long.
Array's are much faster than strings for appends, but I defy you to
do an instr or countfields operation on one of your fast strings....
I did mention that my FastString class is "more evolved".
You CAN do this operation on my FastString class :) via it's .Buffer
property :)
And you can do it, WITHOUT killing off the speed :) Or without
breaking mutability. Let me tell you pulling this trick off to get
"The best of both" was not easy though.
It has one requirement though to do this. Just don't keep a .Buffer
around and shorten the FastString class. Otherwise FastString is
forced to create a whole new buffer. If you just append stuff I think
FastString should cope. But if you shorten the FastString, then you
are writing into "viewed" data, and your data would become live. To
avoid this mutability issue FastString will recreate it's own buffer.
This would be a waste of time and RAM.
But it's very rare as few people shorten their FastString's anyhow.
So basically uou can get the best of both, with ElfData :)
Different horses for different courses Kem....
Some horses can do both courses.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>