aboutsummaryrefslogtreecommitdiffstats
path: root/components/util
diff options
context:
space:
mode:
Diffstat (limited to 'components/util')
-rw-r--r--components/util/Cargo.toml3
-rw-r--r--components/util/bloom.rs2
-rw-r--r--components/util/cache.rs2
-rw-r--r--components/util/lib.rs2
-rw-r--r--components/util/memory.rs7
-rw-r--r--components/util/smallvec.rs48
-rw-r--r--components/util/sort.rs2
-rw-r--r--components/util/time.rs5
-rw-r--r--components/util/workqueue.rs10
9 files changed, 41 insertions, 40 deletions
diff --git a/components/util/Cargo.toml b/components/util/Cargo.toml
index 0bbc9581349..3e599630f0c 100644
--- a/components/util/Cargo.toml
+++ b/components/util/Cargo.toml
@@ -18,7 +18,6 @@ path = "../../support/rust-task_info"
[dependencies.string_cache]
git = "https://github.com/servo/string-cache"
-branch = "pre-rustup"
[dependencies.url]
-git = "https://github.com/servo/rust-url" \ No newline at end of file
+git = "https://github.com/servo/rust-url"
diff --git a/components/util/bloom.rs b/components/util/bloom.rs
index 0019092663f..4621697fa50 100644
--- a/components/util/bloom.rs
+++ b/components/util/bloom.rs
@@ -262,7 +262,7 @@ impl BloomFilter {
/// on every element.
pub fn clear(&mut self) {
self.number_of_insertions = 0;
- for x in self.buf.as_mut_slice().mut_iter() {
+ for x in self.buf.as_mut_slice().iter_mut() {
*x = 0u;
}
}
diff --git a/components/util/cache.rs b/components/util/cache.rs
index 1b159cea8c1..35d442cd079 100644
--- a/components/util/cache.rs
+++ b/components/util/cache.rs
@@ -238,7 +238,7 @@ impl<K:Clone+PartialEq+Hash,V:Clone> Cache<K,V> for SimpleHashCache<K,V> {
}
fn evict_all(&mut self) {
- for slot in self.entries.mut_iter() {
+ for slot in self.entries.iter_mut() {
*slot = None
}
}
diff --git a/components/util/lib.rs b/components/util/lib.rs
index a62c35ee576..89fcec41d93 100644
--- a/components/util/lib.rs
+++ b/components/util/lib.rs
@@ -25,7 +25,7 @@ extern crate serialize;
extern crate sync;
#[cfg(target_os="macos")]
extern crate task_info;
-extern crate std_time = "time";
+extern crate "time" as std_time;
extern crate string_cache;
extern crate url;
diff --git a/components/util/memory.rs b/components/util/memory.rs
index 25aa13c8316..2c3d92fe1d6 100644
--- a/components/util/memory.rs
+++ b/components/util/memory.rs
@@ -11,7 +11,8 @@ use std::io::File;
use std::mem::size_of;
#[cfg(target_os="linux")]
use std::os::page_size;
-use std::ptr::mut_null;
+use std::ptr::null_mut;
+use std::time::duration::Duration;
use task::spawn_named;
#[cfg(target_os="macos")]
use task_info::task_basic_info::{virtual_size,resident_size};
@@ -41,7 +42,7 @@ impl MemoryProfiler {
let (chan, port) = channel();
match period {
Some(period) => {
- let period = (period * 1000f64) as u64;
+ let period = Duration::milliseconds((period * 1000f64) as i64);
let chan = chan.clone();
spawn_named("Memory profiler timer", proc() {
loop {
@@ -154,7 +155,7 @@ fn get_jemalloc_stat(name: &'static str) -> Option<u64> {
let mut oldlen = size_of::<size_t>() as size_t;
let rv: c_int;
unsafe {
- rv = je_mallctl(c_name.unwrap(), oldp, &mut oldlen, mut_null(), 0);
+ rv = je_mallctl(c_name.unwrap(), oldp, &mut oldlen, null_mut(), 0);
}
if rv == 0 { Some(old as u64) } else { None }
}
diff --git a/components/util/smallvec.rs b/components/util/smallvec.rs
index 4b926c78701..c5a9c87e84c 100644
--- a/components/util/smallvec.rs
+++ b/components/util/smallvec.rs
@@ -5,7 +5,7 @@
//! Small vectors in various sizes. These store a certain number of elements inline and fall back
//! to the heap for larger allocations.
-use i = std::mem::init;
+use std::mem::init as i;
use std::cmp;
use std::intrinsics;
use std::kinds::marker::ContravariantLifetime;
@@ -21,12 +21,12 @@ pub trait VecLike<T> {
fn vec_len(&self) -> uint;
fn vec_push(&mut self, value: T);
- fn vec_mut_slice<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T];
+ fn vec_slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T];
#[inline]
- fn vec_mut_slice_from<'a>(&'a mut self, start: uint) -> &'a mut [T] {
+ fn vec_slice_from_mut<'a>(&'a mut self, start: uint) -> &'a mut [T] {
let len = self.vec_len();
- self.vec_mut_slice(start, len)
+ self.vec_slice_mut(start, len)
}
}
@@ -42,8 +42,8 @@ impl<T> VecLike<T> for Vec<T> {
}
#[inline]
- fn vec_mut_slice<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T] {
- self.mut_slice(start, end)
+ fn vec_slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T] {
+ self.slice_mut(start, end)
}
}
@@ -57,7 +57,7 @@ trait SmallVecPrivate<T> {
unsafe fn set_ptr(&mut self, new_ptr: *mut T);
}
-pub trait SmallVec<T> : SmallVecPrivate<T> {
+pub trait SmallVec<T> : SmallVecPrivate<T> where T: 'static {
fn inline_size(&self) -> uint;
fn len(&self) -> uint;
fn cap(&self) -> uint;
@@ -102,7 +102,7 @@ pub trait SmallVec<T> : SmallVecPrivate<T> {
/// NB: For efficiency reasons (avoiding making a second copy of the inline elements), this
/// actually clears out the original array instead of moving it.
- fn move_iter<'a>(&'a mut self) -> SmallVecMoveIterator<'a,T> {
+ fn into_iter<'a>(&'a mut self) -> SmallVecMoveIterator<'a,T> {
unsafe {
let iter = mem::transmute(self.iter());
let ptr_opt = if self.spilled() {
@@ -136,7 +136,7 @@ pub trait SmallVec<T> : SmallVecPrivate<T> {
}
fn push_all_move<V:SmallVec<T>>(&mut self, mut other: V) {
- for value in other.move_iter() {
+ for value in other.into_iter() {
self.push(value)
}
}
@@ -219,12 +219,12 @@ pub trait SmallVec<T> : SmallVecPrivate<T> {
self.slice(0, self.len())
}
- fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
+ fn as_slice_mut<'a>(&'a mut self) -> &'a mut [T] {
let len = self.len();
- self.mut_slice(0, len)
+ self.slice_mut(0, len)
}
- fn mut_slice<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T] {
+ fn slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T] {
assert!(start <= end);
assert!(end <= self.len());
unsafe {
@@ -235,9 +235,9 @@ pub trait SmallVec<T> : SmallVecPrivate<T> {
}
}
- fn mut_slice_from<'a>(&'a mut self, start: uint) -> &'a mut [T] {
+ fn slice_from_mut<'a>(&'a mut self, start: uint) -> &'a mut [T] {
let len = self.len();
- self.mut_slice(start, len)
+ self.slice_mut(start, len)
}
fn fail_bounds_check(&self, index: uint) {
@@ -300,7 +300,7 @@ pub struct SmallVecMoveIterator<'a,T> {
lifetime: ContravariantLifetime<'a>,
}
-impl<'a,T> Iterator<T> for SmallVecMoveIterator<'a,T> {
+impl<'a, T: 'static> Iterator<T> for SmallVecMoveIterator<'a,T> {
#[inline]
fn next(&mut self) -> Option<T> {
unsafe {
@@ -317,7 +317,7 @@ impl<'a,T> Iterator<T> for SmallVecMoveIterator<'a,T> {
}
#[unsafe_destructor]
-impl<'a,T> Drop for SmallVecMoveIterator<'a,T> {
+impl<'a, T: 'static> Drop for SmallVecMoveIterator<'a,T> {
fn drop(&mut self) {
// Destroy the remaining elements.
for _ in *self {}
@@ -350,7 +350,7 @@ macro_rules! def_small_vector(
data: [T, ..$size],
}
- impl<T> SmallVecPrivate<T> for $name<T> {
+ impl<T: 'static> SmallVecPrivate<T> for $name<T> {
unsafe fn set_len(&mut self, new_len: uint) {
self.len = new_len
}
@@ -376,7 +376,7 @@ macro_rules! def_small_vector(
}
}
- impl<T> SmallVec<T> for $name<T> {
+ impl<T: 'static> SmallVec<T> for $name<T> {
fn inline_size(&self) -> uint {
$size
}
@@ -388,7 +388,7 @@ macro_rules! def_small_vector(
}
}
- impl<T> VecLike<T> for $name<T> {
+ impl<T: 'static> VecLike<T> for $name<T> {
#[inline]
fn vec_len(&self) -> uint {
self.len()
@@ -400,12 +400,12 @@ macro_rules! def_small_vector(
}
#[inline]
- fn vec_mut_slice<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T] {
- self.mut_slice(start, end)
+ fn vec_slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T] {
+ self.slice_mut(start, end)
}
}
- impl<T> $name<T> {
+ impl<T: 'static> $name<T> {
#[inline]
pub fn new() -> $name<T> {
unsafe {
@@ -432,7 +432,7 @@ def_small_vector!(SmallVec32, 32)
macro_rules! def_small_vector_drop_impl(
($name:ident, $size:expr) => (
#[unsafe_destructor]
- impl<T> Drop for $name<T> {
+ impl<T: 'static> Drop for $name<T> {
fn drop(&mut self) {
if !self.spilled() {
return
@@ -467,7 +467,7 @@ def_small_vector_drop_impl!(SmallVec32, 32)
macro_rules! def_small_vector_clone_impl(
($name:ident) => (
- impl<T:Clone> Clone for $name<T> {
+ impl<T:Clone+'static> Clone for $name<T> {
fn clone(&self) -> $name<T> {
let mut new_vector = $name::new();
for element in self.iter() {
diff --git a/components/util/sort.rs b/components/util/sort.rs
index 32dc52f6574..bf0c37d8ea6 100644
--- a/components/util/sort.rs
+++ b/components/util/sort.rs
@@ -91,7 +91,7 @@ pub mod test {
let len: uint = rng.gen();
let mut v: Vec<int> = rng.gen_iter::<int>().take((len % 32) + 1).collect();
fn compare_ints(a: &int, b: &int) -> Ordering { a.cmp(b) }
- sort::quicksort_by(v.as_mut_slice(), compare_ints);
+ sort::quicksort_by(v.as_slice_mut(), compare_ints);
for i in range(0, v.len() - 1) {
assert!(v.get(i) <= v.get(i + 1))
}
diff --git a/components/util/time.rs b/components/util/time.rs
index cb283ba3e2f..d3e9b5df65d 100644
--- a/components/util/time.rs
+++ b/components/util/time.rs
@@ -10,6 +10,7 @@ use std::comm::{Sender, channel, Receiver};
use std::f64;
use std::iter::AdditiveIterator;
use std::io::timer::sleep;
+use std::time::duration::Duration;
use task::{spawn_named};
use url::Url;
@@ -127,7 +128,7 @@ impl TimeProfiler {
let (chan, port) = channel();
match period {
Some(period) => {
- let period = (period * 1000f64) as u64;
+ let period = Duration::milliseconds((period * 1000f64) as i64);
let chan = chan.clone();
spawn_named("Time profiler timer", proc() {
loop {
@@ -209,7 +210,7 @@ impl TimeProfiler {
"_category_", "_incremental?_", "_iframe?_",
" _url_", " _mean (ms)_", " _median (ms)_",
" _min (ms)_", " _max (ms)_", " _events_");
- for (&(ref category, ref meta), ref mut data) in self.buckets.mut_iter() {
+ for (&(ref category, ref meta), ref mut data) in self.buckets.iter_mut() {
data.sort_by(|a, b| {
if a < b {
Less
diff --git a/components/util/workqueue.rs b/components/util/workqueue.rs
index f7823448243..4924036a6a8 100644
--- a/components/util/workqueue.rs
+++ b/components/util/workqueue.rs
@@ -156,13 +156,13 @@ impl<QueueData: Send, WorkData: Send> WorkerThread<QueueData, WorkData> {
}
/// A handle to the work queue that individual work units have.
-pub struct WorkerProxy<'a, QueueData, WorkData> {
+pub struct WorkerProxy<'a, QueueData: 'a, WorkData: 'a> {
worker: &'a mut Worker<WorkUnit<QueueData, WorkData>>,
ref_count: *mut AtomicUint,
queue_data: *const QueueData,
}
-impl<'a, QueueData, WorkData: Send> WorkerProxy<'a, QueueData, WorkData> {
+impl<'a, QueueData: 'static, WorkData: Send> WorkerProxy<'a, QueueData, WorkData> {
/// Enqueues a block into the work queue.
#[inline]
pub fn push(&mut self, work_unit: WorkUnit<QueueData, WorkData>) {
@@ -229,7 +229,7 @@ impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
}
// Spawn threads.
- for thread in threads.move_iter() {
+ for thread in threads.into_iter() {
TaskBuilder::new().named(task_name).native().spawn(proc() {
let mut thread = thread;
thread.start()
@@ -260,8 +260,8 @@ impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
pub fn run(&mut self) {
// Tell the workers to start.
let mut work_count = AtomicUint::new(self.work_count);
- for worker in self.workers.mut_iter() {
- worker.chan.send(StartMsg(worker.deque.take_unwrap(), &mut work_count, &self.data))
+ for worker in self.workers.iter_mut() {
+ worker.chan.send(StartMsg(worker.deque.take().unwrap(), &mut work_count, &self.data))
}
// Wait for the work to finish.