@@ -1215,31 +1215,31 @@ fn contains_nonascii(x: usize) -> bool {
1215
1215
/// invalid sequence.
1216
1216
#[ inline( always) ]
1217
1217
fn run_utf8_validation ( v : & [ u8 ] ) -> Result < ( ) , Utf8Error > {
1218
- let mut offset = 0 ;
1218
+ let mut index = 0 ;
1219
1219
let len = v. len ( ) ;
1220
1220
1221
1221
let usize_bytes = mem:: size_of :: < usize > ( ) ;
1222
1222
let ascii_block_size = 2 * usize_bytes;
1223
1223
let blocks_end = if len >= ascii_block_size { len - ascii_block_size + 1 } else { 0 } ;
1224
1224
1225
- while offset < len {
1226
- let old_offset = offset ;
1225
+ while index < len {
1226
+ let old_offset = index ;
1227
1227
macro_rules! err { ( ) => { {
1228
1228
return Err ( Utf8Error {
1229
1229
valid_up_to: old_offset
1230
1230
} )
1231
1231
} } }
1232
1232
1233
1233
macro_rules! next { ( ) => { {
1234
- offset += 1 ;
1234
+ index += 1 ;
1235
1235
// we needed data, but there was none: error!
1236
- if offset >= len {
1236
+ if index >= len {
1237
1237
err!( )
1238
1238
}
1239
- v[ offset ]
1239
+ v[ index ]
1240
1240
} } }
1241
1241
1242
- let first = v[ offset ] ;
1242
+ let first = v[ index ] ;
1243
1243
if first >= 128 {
1244
1244
let w = UTF8_CHAR_WIDTH [ first as usize ] ;
1245
1245
let second = next ! ( ) ;
@@ -1282,32 +1282,32 @@ fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
1282
1282
}
1283
1283
_ => err ! ( )
1284
1284
}
1285
- offset += 1 ;
1285
+ index += 1 ;
1286
1286
} else {
1287
1287
// Ascii case, try to skip forward quickly.
1288
1288
// When the pointer is aligned, read 2 words of data per iteration
1289
1289
// until we find a word containing a non-ascii byte.
1290
1290
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 ) ;
1292
1292
if align == 0 {
1293
- while offset < blocks_end {
1293
+ while index < blocks_end {
1294
1294
unsafe {
1295
- let block = ptr. offset ( offset as isize ) as * const usize ;
1295
+ let block = ptr. offset ( index as isize ) as * const usize ;
1296
1296
// break if there is a nonascii byte
1297
1297
let zu = contains_nonascii ( * block) ;
1298
1298
let zv = contains_nonascii ( * block. offset ( 1 ) ) ;
1299
1299
if zu | zv {
1300
1300
break ;
1301
1301
}
1302
1302
}
1303
- offset += ascii_block_size;
1303
+ index += ascii_block_size;
1304
1304
}
1305
1305
// 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 ;
1308
1308
}
1309
1309
} else {
1310
- offset += 1 ;
1310
+ index += 1 ;
1311
1311
}
1312
1312
}
1313
1313
}
0 commit comments