提交 f8618486 编写于 作者: O OGINO Masanori 提交者: Alex Crichton

alloc, arena, test, url, uuid: Elide lifetimes.

Signed-off-by: NOGINO Masanori <masanori.ogino@gmail.com>
上级 2467c6e5
......@@ -226,7 +226,7 @@ impl<T: Clone> Rc<T> {
/// data is cloned if the reference count is greater than one.
#[inline]
#[experimental]
pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
pub fn make_unique(&mut self) -> &mut T {
// Note that we hold a strong reference, which also counts as
// a weak reference, so we only clone if there is an
// additional reference of either kind.
......@@ -247,7 +247,7 @@ pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
impl<T> Deref<T> for Rc<T> {
/// Borrow the value contained in the reference-counted box
#[inline(always)]
fn deref<'a>(&'a self) -> &'a T {
fn deref(&self) -> &T {
&self.inner().value
}
}
......@@ -390,7 +390,7 @@ fn clone(&self) -> Weak<T> {
#[doc(hidden)]
trait RcBoxPtr<T> {
fn inner<'a>(&'a self) -> &'a RcBox<T>;
fn inner(&self) -> &RcBox<T>;
#[inline]
fn strong(&self) -> uint { self.inner().strong.get() }
......@@ -413,12 +413,12 @@ fn weak(&self) -> uint { self.inner().weak.get() }
impl<T> RcBoxPtr<T> for Rc<T> {
#[inline(always)]
fn inner<'a>(&'a self) -> &'a RcBox<T> { unsafe { &(*self._ptr) } }
fn inner(&self) -> &RcBox<T> { unsafe { &(*self._ptr) } }
}
impl<T> RcBoxPtr<T> for Weak<T> {
#[inline(always)]
fn inner<'a>(&'a self) -> &'a RcBox<T> { unsafe { &(*self._ptr) } }
fn inner(&self) -> &RcBox<T> { unsafe { &(*self._ptr) } }
}
#[cfg(test)]
......
......@@ -207,7 +207,7 @@ fn alloc_copy_inner(&self, n_bytes: uint, align: uint) -> *const u8 {
}
#[inline]
fn alloc_copy<'a, T>(&'a self, op: || -> T) -> &'a T {
fn alloc_copy<T>(&self, op: || -> T) -> &T {
unsafe {
let ptr = self.alloc_copy_inner(mem::size_of::<T>(),
mem::min_align_of::<T>());
......@@ -261,7 +261,7 @@ fn alloc_noncopy_inner(&self, n_bytes: uint,
}
#[inline]
fn alloc_noncopy<'a, T>(&'a self, op: || -> T) -> &'a T {
fn alloc_noncopy<T>(&self, op: || -> T) -> &T {
unsafe {
let tydesc = get_tydesc::<T>();
let (ty_ptr, ptr) =
......@@ -285,7 +285,7 @@ fn alloc_noncopy<'a, T>(&'a self, op: || -> T) -> &'a T {
/// Allocate a new item in the arena, using `op` to initialize the value
/// and returning a reference to it.
#[inline]
pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
pub fn alloc<T>(&self, op: || -> T) -> &T {
unsafe {
if intrinsics::needs_drop::<T>() {
self.alloc_noncopy(op)
......@@ -458,13 +458,13 @@ pub fn with_capacity(capacity: uint) -> TypedArena<T> {
/// Allocates an object in the TypedArena, returning a reference to it.
#[inline]
pub fn alloc<'a>(&'a self, object: T) -> &'a T {
pub fn alloc(&self, object: T) -> &T {
if self.ptr == self.end {
self.grow()
}
let ptr: &'a T = unsafe {
let ptr: &'a mut T = mem::transmute(self.ptr);
let ptr: &T = unsafe {
let ptr: &mut T = mem::transmute(self.ptr);
ptr::write(ptr, object);
self.ptr.set(self.ptr.get().offset(1));
ptr
......
......@@ -164,7 +164,7 @@ pub fn new(samples: &[T]) -> Summary<T> {
}
}
impl<'a,T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
// FIXME #11059 handle NaN, inf and overflow
fn sum(self) -> T {
......
......@@ -394,7 +394,7 @@ fn maybe_push_value(map: &mut HashMap<String, Vec<String>>,
}
}
fn split_char_first<'a>(s: &'a str, c: char) -> (&'a str, &'a str) {
fn split_char_first(s: &str, c: char) -> (&str, &str) {
let mut iter = s.splitn(c, 1);
match (iter.next(), iter.next()) {
......@@ -466,7 +466,7 @@ pub fn query_to_str(query: &Query) -> String {
/// };
/// println!("Scheme in use: {}.", scheme); // Scheme in use: https.
/// ```
pub fn get_scheme<'a>(rawurl: &'a str) -> DecodeResult<(&'a str, &'a str)> {
pub fn get_scheme(rawurl: &str) -> DecodeResult<(&str, &str)> {
for (i,c) in rawurl.chars().enumerate() {
let result = match c {
'A' .. 'Z'
......@@ -493,8 +493,8 @@ pub fn get_scheme<'a>(rawurl: &'a str) -> DecodeResult<(&'a str, &'a str)> {
}
// returns userinfo, host, port, and unparsed part, or an error
fn get_authority<'a>(rawurl: &'a str) ->
DecodeResult<(Option<UserInfo>, &'a str, Option<u16>, &'a str)> {
fn get_authority(rawurl: &str) ->
DecodeResult<(Option<UserInfo>, &str, Option<u16>, &str)> {
enum State {
Start, // starting state
PassHostPort, // could be in user or port
......@@ -662,8 +662,7 @@ enum Input {
// returns the path and unparsed part of url, or an error
fn get_path<'a>(rawurl: &'a str, is_authority: bool)
-> DecodeResult<(String, &'a str)> {
fn get_path(rawurl: &str, is_authority: bool) -> DecodeResult<(String, &str)> {
let len = rawurl.len();
let mut end = len;
for (i,c) in rawurl.chars().enumerate() {
......
......@@ -313,7 +313,7 @@ pub fn get_version(&self) -> Option<UuidVersion> {
}
/// Return an array of 16 octets containing the UUID data
pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
pub fn as_bytes(&self) -> &[u8] {
self.bytes.as_slice()
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册