@@ -255,12 +255,12 @@ macro_rules! impl_Display {
255
255
256
256
let quad = remain % 100_00 ;
257
257
remain /= 100_00 ;
258
- let p1 = ( quad / 100 ) as usize * 2 ;
259
- let p2 = ( quad % 100 ) as usize * 2 ;
260
- buf[ offset + 0 ] . write( DEC_DIGITS_LUT [ p1 + 0 ] ) ;
261
- buf[ offset + 1 ] . write( DEC_DIGITS_LUT [ p1 + 1 ] ) ;
262
- buf[ offset + 2 ] . write( DEC_DIGITS_LUT [ p2 + 0 ] ) ;
263
- buf[ offset + 3 ] . write( DEC_DIGITS_LUT [ p2 + 1 ] ) ;
258
+ let i1 = ( quad / 100 ) as usize ;
259
+ let i2 = ( quad % 100 ) as usize ;
260
+ buf[ offset + 0 ] . write( DEC_DIGITS_LUT [ i1 * 2 + 0 ] ) ;
261
+ buf[ offset + 1 ] . write( DEC_DIGITS_LUT [ i1 * 2 + 1 ] ) ;
262
+ buf[ offset + 2 ] . write( DEC_DIGITS_LUT [ i2 * 2 + 0 ] ) ;
263
+ buf[ offset + 3 ] . write( DEC_DIGITS_LUT [ i2 * 2 + 1 ] ) ;
264
264
}
265
265
266
266
// Format per two digits from the lookup table.
@@ -270,24 +270,24 @@ macro_rules! impl_Display {
270
270
unsafe { core:: hint:: assert_unchecked( offset <= buf. len( ) ) }
271
271
offset -= 2 ;
272
272
273
- let p = ( remain % 100 ) as usize * 2 ;
273
+ let i = ( remain % 100 ) as usize ;
274
274
remain /= 100 ;
275
- buf[ offset + 0 ] . write( DEC_DIGITS_LUT [ p + 0 ] ) ;
276
- buf[ offset + 1 ] . write( DEC_DIGITS_LUT [ p + 1 ] ) ;
275
+ buf[ offset + 0 ] . write( DEC_DIGITS_LUT [ i * 2 + 0 ] ) ;
276
+ buf[ offset + 1 ] . write( DEC_DIGITS_LUT [ i * 2 + 1 ] ) ;
277
277
}
278
278
279
279
// Format the last remaining digit, if any.
280
- if offset != 0 && remain != 0 || offset == MAX_DEC_N {
280
+ if offset != 0 && remain != 0 || self == 0 {
281
281
// SAFETY: Offset from the initial buf.len() gets deducted
282
282
// with underflow checks exclusively.
283
283
unsafe { core:: hint:: assert_unchecked( offset <= buf. len( ) ) }
284
284
offset -= 1 ;
285
285
286
286
// Either the compiler sees that remain < 10, or it prevents
287
287
// a boundary check up next.
288
- let p = ( remain % 10 ) as usize * 2 ;
288
+ let i = ( remain & 15 ) as usize ;
289
289
// not used: remain = 0;
290
- buf[ offset] . write( DEC_DIGITS_LUT [ p + 1 ] ) ;
290
+ buf[ offset] . write( DEC_DIGITS_LUT [ i * 2 + 1 ] ) ;
291
291
}
292
292
293
293
// SAFETY: All buf content since offset is set with bytes form
0 commit comments