Re: Is this a dumb way to count chars in a string?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: MP (nospam_at_Thanks.com)
Date: 11/10/04


Date: Wed, 10 Nov 2004 01:08:45 GMT


"J French" <erewhon@nowhere.uk> wrote in message
news:419086b0.7123716@news.btclick.com...
> On Mon, 08 Nov 2004 22:35:32 GMT, "MP" <nospam@Thanks.com> wrote:
>
snip

>
> Note: the use of LSet explicitly prevents String creation

very cool
:-)

>
> Also it might be an idea to check that Count is zero, if not there
> will be 'Count' unterminated opening brackets
>
> If you really want to ensure that it is running at maximum speed you
> could replace Mid$( L$, L9, 1 ) with a boxed up CopyMemory and StrPtr
> However I doubt that it would be much faster

Thanks for that example.
You taught me a new function - lset - never heard of it.
For now I've got what I'm trying to do working pretty well without counting
characters after all.
I don't know if it is inefficient but the split function is working great
for what I need it to do.
I'm guessing that split may be very inefficient since it's creating all
those individual strings and I've read several articles on vb's inefficient
string handling.
However, in my actual application it's faster than I can see so the
efficiency is theoretical at this point.
Though I've just tested with a single text file so far and the timing may
become more obvious when I start to hit a full directory of files.
Maybe I'll try a version using your counting method and try some time
trials.

Thanks to all for their insights and information on this thread.

It is much appreciated.
Mark



Relevant Pages

  • Re: restriction on sum: intentional bug?
    ... inefficient in this case? ... If sum already has two code branches to handle strings, let the string branch do a join. ...
    (comp.lang.python)
  • Re: Moved from C++ to Delphi
    ... >which is inefficient. ... LStrLen does not have to scan the string, ... doing string manipulations, then you need to find something more ...
    (borland.public.delphi.language.objectpascal)
  • Re: Monitor unblock priority
    ... > Trying to synchronize threads in a fixed/predetermined order is highly ... could show you a string being built up inefficiently, ... problem to the one originally posed, namely releasing threads in the ... inefficient, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: read - comma
    ... > But I still feel it is too inefficient, especially the concatenation ... > part and then reversing the string. ...
    (comp.lang.lisp)
  • Re: Text To Columns in Access
    ... Test the size of the array returned by the split function to make sure there ... Function F2(TextIn As String) As String ... Doug Steele, Microsoft Access MVP ...
    (microsoft.public.access.queries)