diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-02-23 09:11:36 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-02-23 09:11:36 +1100 |
| commit | 713ca7d5402fb33ea1ac4f34a50618d60156d1d3 (patch) | |
| tree | d7a4f340fa451b07a6f80e457341e11c404fa049 /src/libstd | |
| parent | 56cf237ee24df51acc05634c962cd20a66477fa4 (diff) | |
| download | rust-713ca7d5402fb33ea1ac4f34a50618d60156d1d3.tar.gz rust-713ca7d5402fb33ea1ac4f34a50618d60156d1d3.zip | |
std: mark two helper functions #[inline].
`str::utf8_char_width` and `char::from_u32` are tiny, which means it's a big performance hit to call them in a tight loop outside libstd.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/char.rs | 1 | ||||
| -rw-r--r-- | src/libstd/str.rs | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/src/libstd/char.rs b/src/libstd/char.rs index 71a297d7176..1ec89d1850f 100644 --- a/src/libstd/char.rs +++ b/src/libstd/char.rs @@ -69,6 +69,7 @@ static TAG_FOUR_B: uint = 240u; pub static MAX: char = '\U0010ffff'; /// Convert from `u32` to a character. +#[inline] pub fn from_u32(i: u32) -> Option<char> { // catch out-of-bounds and surrogates if (i > MAX as u32) || (i >= 0xD800 && i <= 0xDFFF) { diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 123b4957599..ecd297b72a4 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -1061,6 +1061,7 @@ static UTF8_CHAR_WIDTH: [u8, ..256] = [ ]; /// Given a first byte, determine how many bytes are in this UTF-8 character +#[inline] pub fn utf8_char_width(b: u8) -> uint { return UTF8_CHAR_WIDTH[b] as uint; } |
