PE>> Change your algorithm and you should be able to get it close to
PE>> 1.5 seconds doing it the proper way. BFN. Paul.
BL> You have my full attention!
In my experience, everything can be made close to what you would do a
different way, if you think about it. Therefore, although it is not
necessarily what I would do personally, the advice I will give you is
designed so that it mimicks the current way you are doing this, to your
satisfaction. However, since your current method is technically incorrect,
I would not expect the technically correct method to be as quick, although
a factor of 22 I think we can manage.
BL> At present, I read a 30K string from the 150K packet. This is
Ok, so continue reading 30K chunks.
BL> read very quickly. Then I search the 30K string for the position
BL> of the first "Rod Speed00" that identifies the message to
be twitted.
Instead, in a loop, do the following.
1. Skip 50 bytes (or whatever the length of the fixed header is). This is a
very inexpensive operation if you were using C, anyway.
See if the string is equal to "Rod Speed" (use memcmp). This is
the "To" field from memory. If it is, then you can do your copy
of the good stuff to the file, like you are doing now. If it isn't, search
for a '\0'. Use strlen() to do this, assuming you have a compiler that
inlines strlen(). Otherwise read the characters one at a time with a
pointer.
Then look at the next string, the From field, to see if it is equal to Rod
Speed. Ditto.
Look for the NUL that finishes the string. Look for the next NUL that
finishes the subject. Look for the NUL that finishes the message, see if
the next character is '\x00' or '\x02' and decide whether to finish or read
the next message.
The operations thus come down to skipping 50 bytes, doing a string compare,
and doing a search for NUL. On an 80x86 machine these all come down to
just a couple of operations each. BFN. Paul.
|