@@ -1215,31 +1215,31 @@ fn contains_nonascii(x: usize) -> bool {
12151215/// invalid sequence.
12161216#[ inline( always) ]
12171217fn run_utf8_validation ( v : & [ u8 ] ) -> Result < ( ) , Utf8Error > {
1218- let mut offset = 0 ;
1218+ let mut index = 0 ;
12191219 let len = v. len ( ) ;
12201220
12211221 let usize_bytes = mem:: size_of :: < usize > ( ) ;
12221222 let ascii_block_size = 2 * usize_bytes;
12231223 let blocks_end = if len >= ascii_block_size { len - ascii_block_size + 1 } else { 0 } ;
12241224
1225- while offset < len {
1226- let old_offset = offset ;
1225+ while index < len {
1226+ let old_offset = index ;
12271227 macro_rules! err { ( ) => { {
12281228 return Err ( Utf8Error {
12291229 valid_up_to: old_offset
12301230 } )
12311231 } } }
12321232
12331233 macro_rules! next { ( ) => { {
1234- offset += 1 ;
1234+ index += 1 ;
12351235 // we needed data, but there was none: error!
1236- if offset >= len {
1236+ if index >= len {
12371237 err!( )
12381238 }
1239- v[ offset ]
1239+ v[ index ]
12401240 } } }
12411241
1242- let first = v[ offset ] ;
1242+ let first = v[ index ] ;
12431243 if first >= 128 {
12441244 let w = UTF8_CHAR_WIDTH [ first as usize ] ;
12451245 let second = next ! ( ) ;
@@ -1282,32 +1282,32 @@ fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
12821282 }
12831283 _ => err ! ( )
12841284 }
1285- offset += 1 ;
1285+ index += 1 ;
12861286 } else {
12871287 // Ascii case, try to skip forward quickly.
12881288 // When the pointer is aligned, read 2 words of data per iteration
12891289 // until we find a word containing a non-ascii byte.
12901290 let ptr = v. as_ptr ( ) ;
1291- let align = ( ptr as usize + offset ) & ( usize_bytes - 1 ) ;
1291+ let align = ( ptr as usize + index ) & ( usize_bytes - 1 ) ;
12921292 if align == 0 {
1293- while offset < blocks_end {
1293+ while index < blocks_end {
12941294 unsafe {
1295- let block = ptr. offset ( offset as isize ) as * const usize ;
1295+ let block = ptr. offset ( index as isize ) as * const usize ;
12961296 // break if there is a nonascii byte
12971297 let zu = contains_nonascii ( * block) ;
12981298 let zv = contains_nonascii ( * block. offset ( 1 ) ) ;
12991299 if zu | zv {
13001300 break ;
13011301 }
13021302 }
1303- offset += ascii_block_size;
1303+ index += ascii_block_size;
13041304 }
13051305 // step from the point where the wordwise loop stopped
1306- while offset < len && v[ offset ] < 128 {
1307- offset += 1 ;
1306+ while index < len && v[ index ] < 128 {
1307+ index += 1 ;
13081308 }
13091309 } else {
1310- offset += 1 ;
1310+ index += 1 ;
13111311 }
13121312 }
13131313 }
0 commit comments