C
Chance Hopkins
Background
---------------
I'm running some tests on a for loop where I need to split a string at the
first whitespace and get all characters from the start of the line to the
first space.
I'm using two methods and getting almost exact results (every test run
varies a bit) from either:
obj.Add(myString..Split(new char[]{' '})[0]);
or
Regex myRegex = new Regex(@"[^\s]+"); <-- outside loop of course
obj.Add(myRegex.Match(myString).ToString());
It takes about 50-58 seconds to go through a list of 800.
Question
-----------------
I read a post where they mentioned the possibility of using unsafe code with
a pointer to move through the string to the first whitespace and suggested
this might be fastest.
Could anyone give me an idea of how to do this with a simple string or point
me at the proper reading material.
I know csharp and java pretty well, but don't really understand the c or c++
stuff.
Thanks
---------------
I'm running some tests on a for loop where I need to split a string at the
first whitespace and get all characters from the start of the line to the
first space.
I'm using two methods and getting almost exact results (every test run
varies a bit) from either:
obj.Add(myString..Split(new char[]{' '})[0]);
or
Regex myRegex = new Regex(@"[^\s]+"); <-- outside loop of course
obj.Add(myRegex.Match(myString).ToString());
It takes about 50-58 seconds to go through a list of 800.
Question
-----------------
I read a post where they mentioned the possibility of using unsafe code with
a pointer to move through the string to the first whitespace and suggested
this might be fastest.
Could anyone give me an idea of how to do this with a simple string or point
me at the proper reading material.
I know csharp and java pretty well, but don't really understand the c or c++
stuff.
Thanks