diff options
Diffstat (limited to 'components/util')
-rw-r--r-- | components/util/cache.rs | 2 | ||||
-rw-r--r-- | components/util/cursor.rs | 4 | ||||
-rw-r--r-- | components/util/deque/mod.rs | 12 | ||||
-rw-r--r-- | components/util/mem.rs | 50 | ||||
-rw-r--r-- | components/util/opts.rs | 2 | ||||
-rw-r--r-- | components/util/persistent_list.rs | 3 | ||||
-rw-r--r-- | components/util/prefs.rs | 22 | ||||
-rw-r--r-- | components/util/str.rs | 7 | ||||
-rw-r--r-- | components/util/vec.rs | 2 | ||||
-rw-r--r-- | components/util/workqueue.rs | 8 |
10 files changed, 55 insertions, 57 deletions
diff --git a/components/util/cache.rs b/components/util/cache.rs index 4bb02353702..7a3dcfa980f 100644 --- a/components/util/cache.rs +++ b/components/util/cache.rs @@ -76,7 +76,7 @@ impl<K: Clone + PartialEq, V: Clone> LRUCache<K, V> { self.entries[last_index].1.clone() } - pub fn iter<'a>(&'a self) -> Iter<'a, (K, V)> { + pub fn iter(&self) -> Iter<(K, V)> { self.entries.iter() } diff --git a/components/util/cursor.rs b/components/util/cursor.rs index 8e4ca9e3c1c..bda254861e2 100644 --- a/components/util/cursor.rs +++ b/components/util/cursor.rs @@ -26,8 +26,8 @@ macro_rules! define_cursor { impl ToCss for Cursor { fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write { - match self { - $( &Cursor::$variant => dest.write_str($css) ),+ + match *self { + $( Cursor::$variant => dest.write_str($css) ),+ } } } diff --git a/components/util/deque/mod.rs b/components/util/deque/mod.rs index 3764fbf933d..7ee26c9f2bf 100644 --- a/components/util/deque/mod.rs +++ b/components/util/deque/mod.rs @@ -197,7 +197,7 @@ impl<T: Send + 'static> Worker<T> { /// Gets access to the buffer pool that this worker is attached to. This can /// be used to create more deques which share the same buffer pool as this /// deque. - pub fn pool<'a>(&'a self) -> &'a BufferPool<T> { + pub fn pool(&self) -> &BufferPool<T> { &self.deque.pool } } @@ -211,7 +211,7 @@ impl<T: Send + 'static> Stealer<T> { /// Gets access to the buffer pool that this stealer is attached to. This /// can be used to create more deques which share the same buffer pool as /// this deque. - pub fn pool<'a>(&'a self) -> &'a BufferPool<T> { + pub fn pool(&self) -> &BufferPool<T> { &self.deque.pool } } @@ -270,11 +270,11 @@ impl<T: Send + 'static> Deque<T> { } if self.top.compare_and_swap(t, t + 1, SeqCst) == t { self.bottom.store(t + 1, SeqCst); - return Some(data); + Some(data) } else { self.bottom.store(t + 1, SeqCst); forget(data); // someone else stole this value - return None; + None } } @@ -325,7 +325,7 @@ impl<T: Send + 'static> Deque<T> { self.bottom.store(b, SeqCst); } self.pool.free(transmute(old)); - return newbuf; + newbuf } } @@ -393,7 +393,7 @@ impl<T> Buffer<T> { for i in t..b { buf.put(i, self.get(i)); } - return buf; + buf } } diff --git a/components/util/mem.rs b/components/util/mem.rs index 0243dd671b9..1577ff39dc2 100644 --- a/components/util/mem.rs +++ b/components/util/mem.rs @@ -123,9 +123,9 @@ impl HeapSizeOf for url::Url { impl HeapSizeOf for url::SchemeData { fn heap_size_of_children(&self) -> usize { - match self { - &url::SchemeData::Relative(ref data) => data.heap_size_of_children(), - &url::SchemeData::NonRelative(ref str) => str.heap_size_of_children() + match *self { + url::SchemeData::Relative(ref data) => data.heap_size_of_children(), + url::SchemeData::NonRelative(ref str) => str.heap_size_of_children() } } } @@ -147,9 +147,9 @@ impl HeapSizeOf for url::RelativeSchemeData { impl HeapSizeOf for url::Host { fn heap_size_of_children(&self) -> usize { - match self { - &url::Host::Domain(ref str) => str.heap_size_of_children(), - &url::Host::Ipv6(_) => 0 + match *self { + url::Host::Domain(ref str) => str.heap_size_of_children(), + url::Host::Ipv6(_) => 0 } } } @@ -302,8 +302,8 @@ impl<T: Copy + GCMethods<T>> HeapSizeOf for Heap<T> { impl HeapSizeOf for Method { fn heap_size_of_children(&self) -> usize { - match self { - &Method::Extension(ref str) => str.heap_size_of_children(), + match *self { + Method::Extension(ref str) => str.heap_size_of_children(), _ => 0 } } @@ -311,9 +311,9 @@ impl HeapSizeOf for Method { impl<T: HeapSizeOf, U: HeapSizeOf> HeapSizeOf for Result<T, U> { fn heap_size_of_children(&self) -> usize { - match self { - &Result::Ok(ref ok) => ok.heap_size_of_children(), - &Result::Err(ref err) => err.heap_size_of_children() + match *self { + Result::Ok(ref ok) => ok.heap_size_of_children(), + Result::Err(ref err) => err.heap_size_of_children() } } } @@ -341,13 +341,13 @@ impl HeapSizeOf for CompoundSelector { impl HeapSizeOf for SimpleSelector { fn heap_size_of_children(&self) -> usize { - match self { - &SimpleSelector::Negation(ref vec) => vec.heap_size_of_children(), - &SimpleSelector::AttrIncludes(_, ref str) | &SimpleSelector::AttrPrefixMatch(_, ref str) | - &SimpleSelector::AttrSubstringMatch(_, ref str) | &SimpleSelector::AttrSuffixMatch(_, ref str) + match *self { + SimpleSelector::Negation(ref vec) => vec.heap_size_of_children(), + SimpleSelector::AttrIncludes(_, ref str) | SimpleSelector::AttrPrefixMatch(_, ref str) | + SimpleSelector::AttrSubstringMatch(_, ref str) | SimpleSelector::AttrSuffixMatch(_, ref str) => str.heap_size_of_children(), - &SimpleSelector::AttrEqual(_, ref str, _) => str.heap_size_of_children(), - &SimpleSelector::AttrDashMatch(_, ref first, ref second) => first.heap_size_of_children() + SimpleSelector::AttrEqual(_, ref str, _) => str.heap_size_of_children(), + SimpleSelector::AttrDashMatch(_, ref first, ref second) => first.heap_size_of_children() + second.heap_size_of_children(), // All other types come down to Atom, enum or i32, all 0 _ => 0 @@ -372,8 +372,8 @@ impl HeapSizeOf for Mime { impl HeapSizeOf for TopLevel { fn heap_size_of_children(&self) -> usize { - match self { - &TopLevel::Ext(ref str) => str.heap_size_of_children(), + match *self { + TopLevel::Ext(ref str) => str.heap_size_of_children(), _ => 0 } } @@ -381,8 +381,8 @@ impl HeapSizeOf for TopLevel { impl HeapSizeOf for SubLevel { fn heap_size_of_children(&self) -> usize { - match self { - &SubLevel::Ext(ref str) => str.heap_size_of_children(), + match *self { + SubLevel::Ext(ref str) => str.heap_size_of_children(), _ => 0 } } @@ -390,8 +390,8 @@ impl HeapSizeOf for SubLevel { impl HeapSizeOf for Attr { fn heap_size_of_children(&self) -> usize { - match self { - &Attr::Ext(ref str) => str.heap_size_of_children(), + match *self { + Attr::Ext(ref str) => str.heap_size_of_children(), _ => 0 } } @@ -399,8 +399,8 @@ impl HeapSizeOf for Attr { impl HeapSizeOf for Value { fn heap_size_of_children(&self) -> usize { - match self { - &Value::Ext(ref str) => str.heap_size_of_children(), + match *self { + Value::Ext(ref str) => str.heap_size_of_children(), _ => 0 } } diff --git a/components/util/opts.rs b/components/util/opts.rs index d3b25743431..ea1d9609264 100644 --- a/components/util/opts.rs +++ b/components/util/opts.rs @@ -257,7 +257,7 @@ pub struct DebugOptions { impl DebugOptions { - pub fn new<'a>(debug_string: &'a str) -> Result<DebugOptions, &'a str> { + pub fn new(debug_string: &str) -> Result<DebugOptions, &str> { let mut debug_options = DebugOptions::default(); for option in debug_string.split(',') { diff --git a/components/util/persistent_list.rs b/components/util/persistent_list.rs index 9043fe76e54..210606f1d5d 100644 --- a/components/util/persistent_list.rs +++ b/components/util/persistent_list.rs @@ -49,7 +49,7 @@ impl<T> PersistentList<T> where T: Send + Sync { } #[inline] - pub fn iter<'a>(&'a self) -> PersistentListIterator<'a, T> { + pub fn iter(&self) -> PersistentListIterator<T> { // This could clone (and would not need the lifetime if it did), but then it would incur // atomic operations on every call to `.next()`. Bad. PersistentListIterator { @@ -90,4 +90,3 @@ impl<'a, T> Iterator for PersistentListIterator<'a, T> where T: Send + Sync + 's Some(value) } } - diff --git a/components/util/prefs.rs b/components/util/prefs.rs index 9762e1865af..b73bf9158d9 100644 --- a/components/util/prefs.rs +++ b/components/util/prefs.rs @@ -34,8 +34,8 @@ impl PrefValue { } pub fn as_boolean(&self) -> Option<bool> { - match self { - &PrefValue::Boolean(value) => { + match *self { + PrefValue::Boolean(value) => { Some(value) }, _ => None @@ -87,12 +87,12 @@ impl Pref { } pub fn value(&self) -> &Arc<PrefValue> { - match self { - &Pref::NoDefault(ref x) => x, - &Pref::WithDefault(ref default, ref override_value) => { - match override_value { - &Some(ref x) => x, - &None => default + match *self { + Pref::NoDefault(ref x) => x, + Pref::WithDefault(ref default, ref override_value) => { + match *override_value { + Some(ref x) => x, + None => default } } } @@ -101,11 +101,11 @@ impl Pref { fn set(&mut self, value: PrefValue) { // TODO - this should error if we try to override a pref of one type // with a value of a different type - match self { - &mut Pref::NoDefault(ref mut pref_value) => { + match *self { + Pref::NoDefault(ref mut pref_value) => { *pref_value = Arc::new(value) }, - &mut Pref::WithDefault(_, ref mut override_value) => { + Pref::WithDefault(_, ref mut override_value) => { *override_value = Some(Arc::new(value)) } } diff --git a/components/util/str.rs b/components/util/str.rs index ef84853493c..35f7ff4efcf 100644 --- a/components/util/str.rs +++ b/components/util/str.rs @@ -97,7 +97,7 @@ fn do_parse_integer<T: Iterator<Item=char>>(input: T) -> Option<i64> { let value = read_numbers(input); - return value.and_then(|value| value.checked_mul(sign)); + value.and_then(|value| value.checked_mul(sign)) } /// Parse an integer according to @@ -244,9 +244,8 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA, ()> { } // Step 5. - match cssparser::parse_color_keyword(input) { - Ok(Color::RGBA(rgba)) => return Ok(rgba), - _ => {} + if let Ok(Color::RGBA(rgba)) = cssparser::parse_color_keyword(input) { + return Ok(rgba); } // Step 6. diff --git a/components/util/vec.rs b/components/util/vec.rs index 808aeb96479..ce4ac1f570a 100644 --- a/components/util/vec.rs +++ b/components/util/vec.rs @@ -52,7 +52,7 @@ impl<T> FullBinarySearchMethods<T> for [T] { Ordering::Equal => return Some(mid), } } - return None; + None } } diff --git a/components/util/workqueue.rs b/components/util/workqueue.rs index af481312f21..26125335b3e 100644 --- a/components/util/workqueue.rs +++ b/components/util/workqueue.rs @@ -259,13 +259,13 @@ impl<QueueData: Sync, WorkData: Send> WorkQueue<QueueData, WorkData> { } // Connect workers to one another. - for i in 0..thread_count { - for j in 0..thread_count { + for (i, mut thread) in threads.iter_mut().enumerate() { + for (j, info) in infos.iter().enumerate() { if i != j { - threads[i].other_deques.push(infos[j].thief.clone()) + thread.other_deques.push(info.thief.clone()) } } - assert!(threads[i].other_deques.len() == thread_count - 1) + assert!(thread.other_deques.len() == thread_count - 1) } // Spawn threads. |