Skip to content

Commit

Permalink
add inline to every String function
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Orth committed Jan 10, 2015
1 parent d36dc15 commit a03ae68
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/libcollections/string.rs
Expand Up @@ -302,6 +302,7 @@ impl String {
/// assert_eq!(String::from_utf16_lossy(v),
/// "𝄞mus\u{FFFD}ic\u{FFFD}".to_string());
/// ```
#[inline]
#[stable]
pub fn from_utf16_lossy(v: &[u16]) -> String {
unicode_str::utf16_items(v).map(|c| c.to_char_lossy()).collect()
Expand Down Expand Up @@ -556,6 +557,7 @@ impl String {
/// assert_eq!(s.remove(1), 'o');
/// assert_eq!(s.remove(0), 'o');
/// ```
#[inline]
#[stable]
pub fn remove(&mut self, idx: uint) -> char {
let len = self.len();
Expand All @@ -582,6 +584,7 @@ impl String {
///
/// If `idx` does not lie on a character boundary or is out of bounds, then
/// this function will panic.
#[inline]
#[stable]
pub fn insert(&mut self, idx: uint, ch: char) {
let len = self.len();
Expand Down Expand Up @@ -618,6 +621,7 @@ impl String {
/// }
/// assert_eq!(s.as_slice(), "olleh");
/// ```
#[inline]
#[stable]
pub unsafe fn as_mut_vec<'a>(&'a mut self) -> &'a mut Vec<u8> {
&mut self.vec
Expand Down Expand Up @@ -645,6 +649,7 @@ impl String {
/// v.push('a');
/// assert!(!v.is_empty());
/// ```
#[inline]
#[stable]
pub fn is_empty(&self) -> bool { self.len() == 0 }

Expand Down Expand Up @@ -801,6 +806,7 @@ impl Str for String {

#[stable]
impl Default for String {
#[inline]
#[stable]
fn default() -> String {
String::new()
Expand All @@ -809,13 +815,15 @@ impl Default for String {

#[stable]
impl fmt::String for String {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(&**self, f)
}
}

#[unstable = "waiting on fmt stabilization"]
impl fmt::Show for String {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Show::fmt(&**self, f)
}
Expand All @@ -842,6 +850,7 @@ impl<H: hash::Writer + hash::Hasher> hash::Hash<H> for String {
impl<'a> Add<&'a str> for String {
type Output = String;

#[inline]
fn add(mut self, other: &str) -> String {
self.push_str(other);
self
Expand Down Expand Up @@ -881,6 +890,7 @@ impl ops::Index<ops::FullRange> for String {
impl ops::Deref for String {
type Target = str;

#[inline]
fn deref<'a>(&'a self) -> &'a str {
unsafe { mem::transmute(&self.vec[]) }
}
Expand All @@ -895,6 +905,7 @@ pub struct DerefString<'a> {
impl<'a> Deref for DerefString<'a> {
type Target = String;

#[inline]
fn deref<'b>(&'b self) -> &'b String {
unsafe { mem::transmute(&*self.x) }
}
Expand Down Expand Up @@ -933,6 +944,7 @@ pub trait ToString {
}

impl<T: fmt::String + ?Sized> ToString for T {
#[inline]
fn to_string(&self) -> String {
use core::fmt::Writer;
let mut buf = String::new();
Expand All @@ -943,12 +955,14 @@ impl<T: fmt::String + ?Sized> ToString for T {
}

impl IntoCow<'static, String, str> for String {
#[inline]
fn into_cow(self) -> CowString<'static> {
Cow::Owned(self)
}
}

impl<'a> IntoCow<'a, String, str> for &'a str {
#[inline]
fn into_cow(self) -> CowString<'a> {
Cow::Borrowed(self)
}
Expand All @@ -966,6 +980,7 @@ impl<'a> Str for CowString<'a> {
}

impl fmt::Writer for String {
#[inline]
fn write_str(&mut self, s: &str) -> fmt::Result {
self.push_str(s);
Ok(())
Expand Down

12 comments on commit a03ae68

@bors
Copy link
Contributor

@bors bors commented on a03ae68 Jan 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from nikomatsakis
at mahkoh@a03ae68

@bors
Copy link
Contributor

@bors bors commented on a03ae68 Jan 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging mahkoh/rust/as_mut_vec = a03ae68 into auto

@bors
Copy link
Contributor

@bors bors commented on a03ae68 Jan 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status: {"merge_sha": "9fe747937a57a8bdb5510016d96fdcb15b9077c0"}

@bors
Copy link
Contributor

@bors bors commented on a03ae68 Jan 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mahkoh/rust/as_mut_vec = a03ae68 merged ok, testing candidate = 9fe7479

@bors
Copy link
Contributor

@bors bors commented on a03ae68 Jan 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a03ae68 Jan 11, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from nikomatsakis
at mahkoh@a03ae68

@bors
Copy link
Contributor

@bors bors commented on a03ae68 Jan 11, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging mahkoh/rust/as_mut_vec = a03ae68 into auto

@bors
Copy link
Contributor

@bors bors commented on a03ae68 Jan 11, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status: {"merge_sha": "9d2e9b9be62316f0bae4ac833c2485f55915ee6c"}

@bors
Copy link
Contributor

@bors bors commented on a03ae68 Jan 11, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mahkoh/rust/as_mut_vec = a03ae68 merged ok, testing candidate = 9d2e9b9

@bors
Copy link
Contributor

@bors bors commented on a03ae68 Jan 11, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 9d2e9b9

@bors
Copy link
Contributor

@bors bors commented on a03ae68 Jan 11, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 9d2e9b9

Please sign in to comment.