This is a byproduct of a discussion on some other issues .
Suppose I need to parse a huge number of very long lines. Each line contains a double
sequence (in a textual representation, of course), separated by a space. I need to parse double
into List<double>
.
The standard parsing method (using string.Split
+ double.TryParse
) seems rather slow: for each of the numbers we need to select a line.
I tried to make it the old C-like way: compute the beginning and end indices of substrings containing numbers, and parse it βin placeβ without creating an extra line. (See http://ideone.com/Op6h0 , the relevant part is shown below.)
int startIdx, endIdx = 0; while(true) { startIdx = endIdx; // no find_first_not_of in C
There is an overload of string.IndexOf
, searching only inside the given substring, but I could not find a method for parsing the double from the substring, without first extracting this substring.
Does anyone have any ideas?
source share