Skip to content

Commit 8c09515

Browse files
committed
rename {max=>largest}_max_leb128_len
1 parent 050cee4 commit 8c09515

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler/rustc_serialize/src/leb128.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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
22
pub 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

compiler/rustc_serialize/src/opaque.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::leb128::{self, max_max_leb128_len};
1+
use crate::leb128::{self, largest_max_leb128_len};
22
use crate::serialize::{Decodable, Decoder, Encodable, Encoder};
33
use std::convert::TryInto;
44
use 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)

0 commit comments

Comments
 (0)