File tree 2 files changed +6
-6
lines changed
compiler/rustc_serialize/src
2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change 1
- /// Returns the longest LEB128 encoding for `T`, assuming `T` is an integer type
1
+ /// Returns the length of the longest LEB128 encoding for `T`, assuming `T` is an integer type
2
2
pub const fn max_leb128_len < T > ( ) -> usize {
3
3
// The longest LEB128 encoding for an integer uses 7 bits per byte.
4
4
( std:: mem:: size_of :: < T > ( ) * 8 + 6 ) / 7
5
5
}
6
6
7
- /// Returns the longest LEB128 encoding of all supported integer types.
8
- pub const fn max_max_leb128_len ( ) -> usize {
7
+ /// Returns the length of the longest LEB128 encoding of all supported integer types.
8
+ pub const fn largest_max_leb128_len ( ) -> usize {
9
9
max_leb128_len :: < u128 > ( )
10
10
}
11
11
Original file line number Diff line number Diff line change 1
- use crate :: leb128:: { self , max_max_leb128_len } ;
1
+ use crate :: leb128:: { self , largest_max_leb128_len } ;
2
2
use crate :: serialize:: { Decodable , Decoder , Encodable , Encoder } ;
3
3
use std:: convert:: TryInto ;
4
4
use std:: fs:: File ;
@@ -186,12 +186,12 @@ impl FileEncoder {
186
186
pub fn with_capacity < P : AsRef < Path > > ( path : P , capacity : usize ) -> io:: Result < Self > {
187
187
// Require capacity at least as large as the largest LEB128 encoding
188
188
// here, so that we don't have to check or handle this on every write.
189
- assert ! ( capacity >= max_max_leb128_len ( ) ) ;
189
+ assert ! ( capacity >= largest_max_leb128_len ( ) ) ;
190
190
191
191
// Require capacity small enough such that some capacity checks can be
192
192
// done using guaranteed non-overflowing add rather than sub, which
193
193
// shaves an instruction off those code paths (on x86 at least).
194
- assert ! ( capacity <= usize :: MAX - max_max_leb128_len ( ) ) ;
194
+ assert ! ( capacity <= usize :: MAX - largest_max_leb128_len ( ) ) ;
195
195
196
196
// Create the file for reading and writing, because some encoders do both
197
197
// (e.g. the metadata encoder when -Zmeta-stats is enabled)
You can’t perform that action at this time.
0 commit comments