aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/util
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-05-08 23:40:15 +0200
committerJack Moffitt <jack@metajack.im>2014-05-22 16:36:40 -0600
commiteaedeb07cb0c4fdda37f35057588e4a769fbe758 (patch)
treecdeb134482f06818f7d6dbad8e008882fcc336a5 /src/components/util
parent3644d0272c89336954358eb5005f884a9c89e8bc (diff)
downloadservo-eaedeb07cb0c4fdda37f35057588e4a769fbe758.tar.gz
servo-eaedeb07cb0c4fdda37f35057588e4a769fbe758.zip
Update Rust.
Diffstat (limited to 'src/components/util')
-rw-r--r--src/components/util/concurrentmap.rs12
-rw-r--r--src/components/util/cowarc.rs6
-rw-r--r--src/components/util/str.rs2
-rw-r--r--src/components/util/task.rs2
-rw-r--r--src/components/util/time.rs8
-rw-r--r--src/components/util/url.rs8
-rw-r--r--src/components/util/workqueue.rs7
7 files changed, 22 insertions, 23 deletions
diff --git a/src/components/util/concurrentmap.rs b/src/components/util/concurrentmap.rs
index 1a2fbd404cf..47a83b2da8a 100644
--- a/src/components/util/concurrentmap.rs
+++ b/src/components/util/concurrentmap.rs
@@ -23,7 +23,7 @@ static LOAD_DENOMINATOR: uint = 4;
/// One bucket in the hash table.
struct Bucket<K,V> {
- next: Option<~Bucket<K,V>>,
+ next: Option<Box<Bucket<K,V>>>,
key: K,
value: V,
}
@@ -116,7 +116,7 @@ impl<K:Hash + Eq,V> ConcurrentHashMap<K,V> {
}
}
- (*bucket).next = Some(~Bucket {
+ (*bucket).next = Some(box Bucket {
next: None,
key: key,
value: value,
@@ -153,7 +153,7 @@ impl<K:Hash + Eq,V> ConcurrentHashMap<K,V> {
let next_opt = mem::replace(&mut bucket.next, None);
match next_opt {
None => nuke_bucket = true,
- Some(~next) => *bucket = next,
+ Some(box next) => *bucket = next,
}
drop(this.size.fetch_sub(1, SeqCst))
}
@@ -175,7 +175,7 @@ impl<K:Hash + Eq,V> ConcurrentHashMap<K,V> {
}
// If we got here, then we found the key. Now do a pointer stitch.
- let ~Bucket {
+ let box Bucket {
next: next_next,
..
} = (*prev).next.take_unwrap();
@@ -314,7 +314,7 @@ impl<K:Hash + Eq,V> ConcurrentHashMap<K,V> {
loop {
match bucket {
None => break,
- Some(~Bucket {
+ Some(box Bucket {
key: key,
value: value,
next: next
@@ -346,7 +346,7 @@ impl<K:Hash + Eq,V> ConcurrentHashMap<K,V> {
#[inline]
fn bucket_and_lock_indices(&self, key: &K) -> (uint, uint) {
let this: &mut ConcurrentHashMap<K,V> = unsafe {
- cast::transmute_mut(cast::transmute_region(self))
+ cast::transmute_mut(cast::transmute_lifetime(self))
};
let hash = sip::hash_with_keys(self.k0, self.k1, key);
diff --git a/src/components/util/cowarc.rs b/src/components/util/cowarc.rs
index c9d7b264157..dbd6709cfcf 100644
--- a/src/components/util/cowarc.rs
+++ b/src/components/util/cowarc.rs
@@ -24,7 +24,7 @@ impl<T> Drop for CowArc<T> {
fn drop(&mut self) {
unsafe {
if self.ptr != ptr::mut_null() && (*self.ptr).ref_count.fetch_sub(1, SeqCst) == 1 {
- let _kill_it: ~CowArcAlloc<T> = cast::transmute(self.ptr);
+ let _kill_it: Box<CowArcAlloc<T>> = cast::transmute(self.ptr);
self.ptr = ptr::mut_null()
}
}
@@ -52,7 +52,7 @@ impl<T:Clone> Clone for CowArc<T> {
impl<T:Clone> CowArc<T> {
#[inline]
pub fn new(value: T) -> CowArc<T> {
- let alloc = ~CowArcAlloc {
+ let alloc = box CowArcAlloc {
ref_count: AtomicUint::new(1),
data: value,
};
@@ -84,7 +84,7 @@ impl<T:Clone> CowArc<T> {
return cast::transmute(&mut (*self.ptr).data)
}
- let copy = ~CowArcAlloc {
+ let copy = box CowArcAlloc {
ref_count: AtomicUint::new(1),
data: (*self.ptr).data.clone(),
};
diff --git a/src/components/util/str.rs b/src/components/util/str.rs
index be5eab6ea52..f9e21a97260 100644
--- a/src/components/util/str.rs
+++ b/src/components/util/str.rs
@@ -20,7 +20,7 @@ pub fn null_str_as_empty(s: &Option<DOMString>) -> DOMString {
pub fn null_str_as_empty_ref<'a>(s: &'a Option<DOMString>) -> &'a str {
match *s {
Some(ref s) => s.as_slice(),
- None => &'a ""
+ None => ""
}
}
diff --git a/src/components/util/task.rs b/src/components/util/task.rs
index 694d617569c..f1d3211d4df 100644
--- a/src/components/util/task.rs
+++ b/src/components/util/task.rs
@@ -8,7 +8,7 @@ use std::comm::Sender;
use std::task::TaskBuilder;
pub fn spawn_named<S: IntoMaybeOwned<'static>>(name: S, f: proc():Send) {
- let builder = task::task().named(name);
+ let builder = task::TaskBuilder::new().named(name);
builder.spawn(f);
}
diff --git a/src/components/util/time.rs b/src/components/util/time.rs
index b04e4fce944..37247b6f041 100644
--- a/src/components/util/time.rs
+++ b/src/components/util/time.rs
@@ -119,7 +119,7 @@ impl Profiler {
spawn_named("Profiler timer", proc() {
loop {
sleep(period);
- if !chan.try_send(PrintMsg) {
+ if chan.send_opt(PrintMsg).is_err() {
break;
}
}
@@ -135,7 +135,7 @@ impl Profiler {
spawn_named("Profiler", proc() {
loop {
match port.recv_opt() {
- None | Some(ExitMsg) => break,
+ Err(_) | Ok(ExitMsg) => break,
_ => {}
}
}
@@ -158,12 +158,12 @@ impl Profiler {
loop {
let msg = self.port.recv_opt();
match msg {
- Some(msg) => {
+ Ok(msg) => {
if !self.handle_msg(msg) {
break
}
}
- None => break
+ _ => break
}
}
}
diff --git a/src/components/util/url.rs b/src/components/util/url.rs
index da2ca64c0e0..7c13e124897 100644
--- a/src/components/util/url.rs
+++ b/src/components/util/url.rs
@@ -18,7 +18,7 @@ Create a URL object from a string. Does various helpful browsery things like
*/
// TODO: about:failure->
pub fn try_parse_url(str_url: &str, base_url: Option<std_url::Url>) -> Result<std_url::Url, ~str> {
- let str_url = str_url.trim_chars(& &[' ', '\t', '\n', '\r', '\x0C']);
+ let str_url = str_url.trim_chars(&[' ', '\t', '\n', '\r', '\x0C']).to_owned();
let schm = std_url::get_scheme(str_url);
let str_url = match schm {
Err(_) => {
@@ -45,11 +45,11 @@ pub fn try_parse_url(str_url: &str, base_url: Option<std_url::Url>) -> Result<st
new_url.scheme + ":" + str_url
} else if base_url.path.is_empty() || str_url.starts_with("/") {
new_url.path = "/".to_owned();
- new_url.to_str() + str_url.trim_left_chars(&'/')
+ new_url.to_str() + str_url.trim_left_chars('/')
} else if str_url.starts_with("#") {
new_url.to_str() + str_url
} else { // relative path
- let base_path = base_url.path.trim_right_chars(&|c: char| c != '/');
+ let base_path = base_url.path.trim_right_chars(|c: char| c != '/');
new_url.path = base_path.to_owned();
new_url.to_str() + str_url
}
@@ -203,7 +203,7 @@ pub fn url_map<T: Clone + 'static>() -> UrlMap<T> {
pub fn is_image_data(uri: &str) -> bool {
- static types: &'static [&'static str] = &[&"data:image/png", &"data:image/gif", &"data:image/jpeg"];
+ static types: &'static [&'static str] = &["data:image/png", "data:image/gif", "data:image/jpeg"];
types.iter().any(|&type_| uri.starts_with(type_))
}
diff --git a/src/components/util/workqueue.rs b/src/components/util/workqueue.rs
index e7314f10812..b2b0f7d844e 100644
--- a/src/components/util/workqueue.rs
+++ b/src/components/util/workqueue.rs
@@ -11,7 +11,6 @@ use native;
use rand;
use rand::{Rng, XorShiftRng};
use std::cast;
-use std::comm;
use std::mem;
use std::sync::atomics::{AtomicUint, SeqCst};
use std::sync::deque::{Abort, BufferPool, Data, Empty, Stealer, Worker};
@@ -116,12 +115,12 @@ impl<QUD:Send,WUD:Send> WorkerThread<QUD,WUD> {
if i == SPIN_COUNT {
match self.port.try_recv() {
- comm::Data(StopMsg) => {
+ Ok(StopMsg) => {
should_continue = false;
break
}
- comm::Data(ExitMsg) => return,
- comm::Data(_) => fail!("unexpected message"),
+ Ok(ExitMsg) => return,
+ Ok(_) => fail!("unexpected message"),
_ => {}
}