rawCoder wrote:
Consider a server which receives delimiter based string data from
client.
It needs to process this data very fast.
I always find such statements to be suspicious. This is the same as saying
"as fast as possible", which, given an infinite amount of development time,
could be quite fast. But no project will support an infinite amount of
development time.
If this is your requirement, change it to something concrete, like "must
process strings from sample data set X with an average time of 12 ms and a
maximum time of 50 ms" or something similar. If this is someone elses
requirement, get them to clarify it in a similar manner.
This allows you to determine when this requirement has been met and when you
can move on to other requirements such as scalability and robustness.
Now if its built in C++, one obvious idea would be to put the string
on heap as char* and then pass the pointer around, delimiter
separated fields will be accessed via pointers as well ( <map> of
pointers to fields ). this will mean that there is no extensive
performance nor memory consumption.
So how this can be done in the most performance friendly way in .NET
Well, for one thing, "in .NET" would include Managed C++ where you could do
this precisely as you've stated.
Secondly, presuming you want to use one of the libraries, I would start with
the Regex library. If you can define your text processing in terms of that,
you likely would find very good performance, given a precompiled RegEx
expression.
http://msdn.microsoft.com/library/de...classtopic.asp
(tiny version:)
http://tinyurl.com/9s84v
Thirdly, if that still isn't good enough, you may want to step back into
(Managed) C++ and look into using the Spirit parser.
HTH
--
Reginald Blue
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my
telephone."
- Bjarne Stroustrup (originator of C++) [quoted at the 2003
International Conference on Intelligent User Interfaces]