@@ -220,23 +220,22 @@ static void LoadInternal( StreamReader reader, string header ) {
220220 unsafe static void Split ( string line , ref string [ ] fields , out int count ) {
221221 // Effectively string.split(',') but without the two passes and memory allocations.
222222 count = 0 ;
223- fixed ( char * ptr = line ) {
224- int start = 0 , len = 0 ;
225- for ( int i = 0 ; i < line . Length ; i ++ ) {
226- if ( ptr [ i ] != ',' ) { len ++ ; continue ; }
227- if ( count == fields . Length )
228- Array . Resize ( ref fields , count + 10 ) ;
229- fields [ count ] = len == 0 ? "" : new String ( ptr , start , len ) ; count ++ ;
230- // Start next string at character after the ,
231- start = i + 1 ;
232- len = 0 ;
233- }
234-
235- // We will always have at least one string, even if it just empty.
223+ int start = 0 , len = 0 ;
224+ for ( int i = 0 ; i < line . Length ; i ++ ) {
225+ if ( line [ i ] != ',' ) { len ++ ; continue ; }
236226 if ( count == fields . Length )
237227 Array . Resize ( ref fields , count + 10 ) ;
238- fields [ count ] = len == 0 ? "" : new String ( ptr , start , len ) ; count ++ ;
228+
229+ fields [ count ] = line . Substring ( start , len ) ; count ++ ;
230+ // Start next string at character after the ,
231+ start = i + 1 ;
232+ len = 0 ;
239233 }
234+
235+ // We will always have at least one string, even if it just empty.
236+ if ( count == fields . Length )
237+ Array . Resize ( ref fields , count + 10 ) ;
238+ fields [ count ] = line . Substring ( start , len ) ; count ++ ;
240239 }
241240
242241
0 commit comments