@@ -17,9 +17,7 @@ use memchr::memchr_iter;
1717use self_cell:: self_cell;
1818use uucore:: error:: { UResult , USimpleError } ;
1919
20- use crate :: {
21- GeneralBigDecimalParseResult , GlobalSettings , Line , SortError , numeric_str_cmp:: NumInfo ,
22- } ;
20+ use crate :: { GeneralBigDecimalParseResult , GlobalSettings , Line , numeric_str_cmp:: NumInfo } ;
2321
2422self_cell ! (
2523 /// The chunk that is passed around between threads.
@@ -41,7 +39,7 @@ pub struct ChunkContents<'a> {
4139
4240#[ derive( Debug ) ]
4341pub struct LineData < ' a > {
44- pub selections : Vec < & ' a str > ,
42+ pub selections : Vec < & ' a [ u8 ] > ,
4543 pub num_infos : Vec < NumInfo > ,
4644 pub parsed_floats : Vec < GeneralBigDecimalParseResult > ,
4745 pub line_num_floats : Vec < Option < f64 > > ,
@@ -68,7 +66,7 @@ impl Chunk {
6866 let selections = unsafe {
6967 // SAFETY: (same as above) It is safe to (temporarily) transmute to a vector of &str with a longer lifetime,
7068 // because the vector is empty.
71- std:: mem:: transmute :: < Vec < & ' _ str > , Vec < & ' static str > > ( std:: mem:: take (
69+ std:: mem:: transmute :: < Vec < & ' _ [ u8 ] > , Vec < & ' static [ u8 ] > > ( std:: mem:: take (
7270 & mut contents. line_data . selections ,
7371 ) )
7472 } ;
@@ -100,7 +98,7 @@ impl Chunk {
10098
10199pub struct RecycledChunk {
102100 lines : Vec < Line < ' static > > ,
103- selections : Vec < & ' static str > ,
101+ selections : Vec < & ' static [ u8 ] > ,
104102 num_infos : Vec < NumInfo > ,
105103 parsed_floats : Vec < GeneralBigDecimalParseResult > ,
106104 line_num_floats : Vec < Option < f64 > > ,
@@ -180,15 +178,14 @@ pub fn read<T: Read>(
180178 let selections = unsafe {
181179 // SAFETY: It is safe to transmute to an empty vector of selections with shorter lifetime.
182180 // It was only temporarily transmuted to a Vec<Line<'static>> to make recycling possible.
183- std:: mem:: transmute :: < Vec < & ' static str > , Vec < & ' _ str > > ( selections)
181+ std:: mem:: transmute :: < Vec < & ' static [ u8 ] > , Vec < & ' _ [ u8 ] > > ( selections)
184182 } ;
185183 let mut lines = unsafe {
186184 // SAFETY: (same as above) It is safe to transmute to a vector of lines with shorter lifetime,
187185 // because it was only temporarily transmuted to a Vec<Line<'static>> to make recycling possible.
188186 std:: mem:: transmute :: < Vec < Line < ' static > > , Vec < Line < ' _ > > > ( lines)
189187 } ;
190- let read = std:: str:: from_utf8 ( & buffer[ ..read] )
191- . map_err ( |error| SortError :: Uft8Error { error } ) ?;
188+ let read = & buffer[ ..read] ;
192189 let mut line_data = LineData {
193190 selections,
194191 num_infos,
@@ -205,13 +202,13 @@ pub fn read<T: Read>(
205202
206203/// Split `read` into `Line`s, and add them to `lines`.
207204fn parse_lines < ' a > (
208- read : & ' a str ,
205+ read : & ' a [ u8 ] ,
209206 lines : & mut Vec < Line < ' a > > ,
210207 line_data : & mut LineData < ' a > ,
211208 separator : u8 ,
212209 settings : & GlobalSettings ,
213210) {
214- let read = read. strip_suffix ( separator as char ) . unwrap_or ( read) ;
211+ let read = read. strip_suffix ( & [ separator] ) . unwrap_or ( read) ;
215212
216213 assert ! ( lines. is_empty( ) ) ;
217214 assert ! ( line_data. selections. is_empty( ) ) ;
@@ -220,7 +217,7 @@ fn parse_lines<'a>(
220217 assert ! ( line_data. line_num_floats. is_empty( ) ) ;
221218 let mut token_buffer = vec ! [ ] ;
222219 lines. extend (
223- read. split ( separator as char )
220+ read. split ( | & c| c == separator )
224221 . enumerate ( )
225222 . map ( |( index, line) | Line :: create ( line, index, line_data, & mut token_buffer, settings) ) ,
226223 ) ;
0 commit comments