11use super :: * ;
2- use unicode_width:: UnicodeWidthChar ;
32
43#[ cfg( test) ]
54mod tests;
@@ -9,15 +8,12 @@ mod tests;
98///
109/// This function will use an SSE2 enhanced implementation if hardware support
1110/// is detected at runtime.
12- pub fn analyze_source_file (
13- src : & str ,
14- ) -> ( Vec < RelativeBytePos > , Vec < MultiByteChar > , Vec < NonNarrowChar > ) {
11+ pub fn analyze_source_file ( src : & str ) -> ( Vec < RelativeBytePos > , Vec < MultiByteChar > ) {
1512 let mut lines = vec ! [ RelativeBytePos :: from_u32( 0 ) ] ;
1613 let mut multi_byte_chars = vec ! [ ] ;
17- let mut non_narrow_chars = vec ! [ ] ;
1814
1915 // Calls the right implementation, depending on hardware support available.
20- analyze_source_file_dispatch ( src, & mut lines, & mut multi_byte_chars, & mut non_narrow_chars ) ;
16+ analyze_source_file_dispatch ( src, & mut lines, & mut multi_byte_chars) ;
2117
2218 // The code above optimistically registers a new line *after* each \n
2319 // it encounters. If that point is already outside the source_file, remove
@@ -30,7 +26,7 @@ pub fn analyze_source_file(
3026 }
3127 }
3228
33- ( lines, multi_byte_chars, non_narrow_chars )
29+ ( lines, multi_byte_chars)
3430}
3531
3632cfg_match ! {
@@ -39,11 +35,10 @@ cfg_match! {
3935 src: & str ,
4036 lines: & mut Vec <RelativeBytePos >,
4137 multi_byte_chars: & mut Vec <MultiByteChar >,
42- non_narrow_chars: & mut Vec <NonNarrowChar >,
4338 ) {
4439 if is_x86_feature_detected!( "sse2" ) {
4540 unsafe {
46- analyze_source_file_sse2( src, lines, multi_byte_chars, non_narrow_chars ) ;
41+ analyze_source_file_sse2( src, lines, multi_byte_chars) ;
4742 }
4843 } else {
4944 analyze_source_file_generic(
@@ -52,7 +47,6 @@ cfg_match! {
5247 RelativeBytePos :: from_u32( 0 ) ,
5348 lines,
5449 multi_byte_chars,
55- non_narrow_chars,
5650 ) ;
5751 }
5852 }
@@ -66,7 +60,6 @@ cfg_match! {
6660 src: & str ,
6761 lines: & mut Vec <RelativeBytePos >,
6862 multi_byte_chars: & mut Vec <MultiByteChar >,
69- non_narrow_chars: & mut Vec <NonNarrowChar >,
7063 ) {
7164 #[ cfg( target_arch = "x86" ) ]
7265 use std:: arch:: x86:: * ;
@@ -159,7 +152,6 @@ cfg_match! {
159152 RelativeBytePos :: from_usize( scan_start) ,
160153 lines,
161154 multi_byte_chars,
162- non_narrow_chars,
163155 ) ;
164156 }
165157
@@ -172,7 +164,6 @@ cfg_match! {
172164 RelativeBytePos :: from_usize( tail_start) ,
173165 lines,
174166 multi_byte_chars,
175- non_narrow_chars,
176167 ) ;
177168 }
178169 }
@@ -183,15 +174,13 @@ cfg_match! {
183174 src: & str ,
184175 lines: & mut Vec <RelativeBytePos >,
185176 multi_byte_chars: & mut Vec <MultiByteChar >,
186- non_narrow_chars: & mut Vec <NonNarrowChar >,
187177 ) {
188178 analyze_source_file_generic(
189179 src,
190180 src. len( ) ,
191181 RelativeBytePos :: from_u32( 0 ) ,
192182 lines,
193183 multi_byte_chars,
194- non_narrow_chars,
195184 ) ;
196185 }
197186 }
@@ -205,7 +194,6 @@ fn analyze_source_file_generic(
205194 output_offset : RelativeBytePos ,
206195 lines : & mut Vec < RelativeBytePos > ,
207196 multi_byte_chars : & mut Vec < MultiByteChar > ,
208- non_narrow_chars : & mut Vec < NonNarrowChar > ,
209197) -> usize {
210198 assert ! ( src. len( ) >= scan_len) ;
211199 let mut i = 0 ;
@@ -227,16 +215,8 @@ fn analyze_source_file_generic(
227215
228216 let pos = RelativeBytePos :: from_usize ( i) + output_offset;
229217
230- match byte {
231- b'\n' => {
232- lines. push ( pos + RelativeBytePos ( 1 ) ) ;
233- }
234- b'\t' => {
235- non_narrow_chars. push ( NonNarrowChar :: Tab ( pos) ) ;
236- }
237- _ => {
238- non_narrow_chars. push ( NonNarrowChar :: ZeroWidth ( pos) ) ;
239- }
218+ if let b'\n' = byte {
219+ lines. push ( pos + RelativeBytePos ( 1 ) ) ;
240220 }
241221 } else if byte >= 127 {
242222 // The slow path:
@@ -252,14 +232,6 @@ fn analyze_source_file_generic(
252232 let mbc = MultiByteChar { pos, bytes : char_len as u8 } ;
253233 multi_byte_chars. push ( mbc) ;
254234 }
255-
256- // Assume control characters are zero width.
257- // FIXME: How can we decide between `width` and `width_cjk`?
258- let char_width = UnicodeWidthChar :: width ( c) . unwrap_or ( 0 ) ;
259-
260- if char_width != 1 {
261- non_narrow_chars. push ( NonNarrowChar :: new ( pos, char_width) ) ;
262- }
263235 }
264236
265237 i += char_len;
0 commit comments