Skip to content

Commit c5d0e2a

Browse files
committed
Add missing #[inline] to methods related to char.
1 parent 8a3f5af commit c5d0e2a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/libcore/char.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ pub trait CharExt {
152152
}
153153

154154
impl CharExt for char {
155+
#[inline]
155156
fn is_digit(self, radix: u32) -> bool {
156157
self.to_digit(radix).is_some()
157158
}
158159

160+
#[inline]
159161
fn to_digit(self, radix: u32) -> Option<u32> {
160162
if radix > 36 {
161163
panic!("to_digit: radix is too high (maximum 36)");
@@ -170,10 +172,12 @@ impl CharExt for char {
170172
else { None }
171173
}
172174

175+
#[inline]
173176
fn escape_unicode(self) -> EscapeUnicode {
174177
EscapeUnicode { c: self, state: EscapeUnicodeState::Backslash }
175178
}
176179

180+
#[inline]
177181
fn escape_default(self) -> EscapeDefault {
178182
let init_state = match self {
179183
'\t' => EscapeDefaultState::Backslash('t'),

src/librustc_unicode/char.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ impl char {
119119
/// assert_eq!('f'.to_digit(16), Some(15));
120120
/// ```
121121
#[stable(feature = "rust1", since = "1.0.0")]
122+
#[inline]
122123
pub fn to_digit(self, radix: u32) -> Option<u32> { C::to_digit(self, radix) }
123124

124125
/// Returns an iterator that yields the hexadecimal Unicode escape of a
@@ -157,6 +158,7 @@ impl char {
157158
/// assert_eq!(heart, r"\u{2764}");
158159
/// ```
159160
#[stable(feature = "rust1", since = "1.0.0")]
161+
#[inline]
160162
pub fn escape_unicode(self) -> EscapeUnicode { C::escape_unicode(self) }
161163

162164
/// Returns an iterator that yields the 'default' ASCII and
@@ -195,6 +197,7 @@ impl char {
195197
/// assert_eq!(quote, "\\\"");
196198
/// ```
197199
#[stable(feature = "rust1", since = "1.0.0")]
200+
#[inline]
198201
pub fn escape_default(self) -> EscapeDefault { C::escape_default(self) }
199202

200203
/// Returns the number of bytes this character would need if encoded in
@@ -208,6 +211,7 @@ impl char {
208211
/// assert_eq!(n, 2);
209212
/// ```
210213
#[stable(feature = "rust1", since = "1.0.0")]
214+
#[inline]
211215
pub fn len_utf8(self) -> usize { C::len_utf8(self) }
212216

213217
/// Returns the number of 16-bit code units this character would need if
@@ -221,6 +225,7 @@ impl char {
221225
/// assert_eq!(n, 1);
222226
/// ```
223227
#[stable(feature = "rust1", since = "1.0.0")]
228+
#[inline]
224229
pub fn len_utf16(self) -> usize { C::len_utf16(self) }
225230

226231
/// Encodes this character as UTF-8 into the provided byte buffer, and then
@@ -255,6 +260,7 @@ impl char {
255260
/// ```
256261
#[unstable(feature = "unicode",
257262
reason = "pending decision about Iterator/Writer/Reader")]
263+
#[inline]
258264
pub fn encode_utf8(self, dst: &mut [u8]) -> Option<usize> { C::encode_utf8(self, dst) }
259265

260266
/// Encodes this character as UTF-16 into the provided `u16` buffer, and
@@ -289,6 +295,7 @@ impl char {
289295
/// ```
290296
#[unstable(feature = "unicode",
291297
reason = "pending decision about Iterator/Writer/Reader")]
298+
#[inline]
292299
pub fn encode_utf16(self, dst: &mut [u16]) -> Option<usize> { C::encode_utf16(self, dst) }
293300

294301
/// Returns whether the specified character is considered a Unicode
@@ -451,5 +458,6 @@ impl char {
451458
since = "1.0.0")]
452459
#[unstable(feature = "unicode",
453460
reason = "needs expert opinion. is_cjk flag stands out as ugly")]
461+
#[inline]
454462
pub fn width(self, is_cjk: bool) -> Option<usize> { charwidth::width(self, is_cjk) }
455463
}

0 commit comments

Comments
 (0)