Re: Performance Question
From: MikeD (nobody_at_nowhere.edu)
Date: 09/22/04
- Next message: Rick Rothstein: "Re: part of a text string"
- Previous message: Larry Serflaten: "Re: Using ListView to display thumbnails"
- In reply to: Bob O`Bob: "Re: Performance Question"
- Next in thread: J French: "Re: Performance Question"
- Reply: J French: "Re: Performance Question"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 21 Sep 2004 21:13:52 -0400
"Bob O`Bob" <filterbob@yahoogroups.com> wrote in message
news:e1SvfeDoEHA.3392@TK2MSFTNGP15.phx.gbl...
> MikeD wrote:
>
>
> > Redimming, especially with the Preserve keyword, it extremely
inefficient.
> > It's almost always better to Redim as few times as possible. If I
> > understand right, a CR is your delimitter. You shouldn't have to loop
> > through the string twice. You can get the number of elements you'll
need by
> > something like this:
> >
> > UBound(Split(mystring, vbCr)) + 1 'add 1 because array is 0-based
>
>
> don't you think it's a little silly to say that you're going to cut down
> on the number of times looping through the data, and then call Split()
> (which ... loops through the data!), only to throw away its results?
No. Split is more efficient than actually looping through the string. Ken
is currently considering looping through the entire string once (parsing it
as he loops through it) just to get the number of elements needed (IOW, to
know what he needs to dim the array to); and then looping through it a
second time (parsing it yet again) to assign the data to the array. Using
Split is more efficient than doing that.
Do YOU know exactly how Split operates behind the scenes? I'll admit that I
don't. But I'm guessing it does it more efficiently than looping and
parsing *string* data yourself (and surely you won't argue that VB does not
handle strings all that efficiently).
And where is the result of Split being "thrown away"? It's being used to get
the upper dimension. If you don't want to "throw away" the array it
returns, then assign the array to a variable and use UBound on that variable
(and maybe you can even reuse the variable). Sheesh! It wasn't meant to be
a "thrown-in" example.
Mike
::::::Off-topic and a rant:::::::
This is what I'm talking about Bob! How many times have Rick, Ken, Larry,
etc (IOW, regulars) or anybody else suggested using Split for this EXACT
same purpose? I've never seen you "question" them on it. If you have,
provide a link to the message.
- Next message: Rick Rothstein: "Re: part of a text string"
- Previous message: Larry Serflaten: "Re: Using ListView to display thumbnails"
- In reply to: Bob O`Bob: "Re: Performance Question"
- Next in thread: J French: "Re: Performance Question"
- Reply: J French: "Re: Performance Question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|