This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
compiler/rustc_serialize/src Expand file tree Collapse file tree 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
22pub const fn max_leb128_len < T > ( ) -> usize {
33 // The longest LEB128 encoding for an integer uses 7 bits per byte.
44 ( std:: mem:: size_of :: < T > ( ) * 8 + 6 ) / 7
55}
66
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 {
99 max_leb128_len :: < u128 > ( )
1010}
1111
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 } ;
22use crate :: serialize:: { Decodable , Decoder , Encodable , Encoder } ;
33use std:: convert:: TryInto ;
44use std:: fs:: File ;
@@ -186,12 +186,12 @@ impl FileEncoder {
186186 pub fn with_capacity < P : AsRef < Path > > ( path : P , capacity : usize ) -> io:: Result < Self > {
187187 // Require capacity at least as large as the largest LEB128 encoding
188188 // 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 ( ) ) ;
190190
191191 // Require capacity small enough such that some capacity checks can be
192192 // done using guaranteed non-overflowing add rather than sub, which
193193 // 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 ( ) ) ;
195195
196196 // Create the file for reading and writing, because some encoders do both
197197 // (e.g. the metadata encoder when -Zmeta-stats is enabled)
You can’t perform that action at this time.
0 commit comments