Auto merge of #5857 - Ms2ger:preshints, r=pcwalton

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5857)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-04-28 03:24:14 -05:00
commit 1cb012fc50
6 changed files with 115 additions and 108 deletions

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use selectors::smallvec::VecLike;
use std::cmp::{PartialOrd, PartialEq, Ordering};
use std::iter::range_step;
@ -72,3 +74,37 @@ pub fn byte_swap(data: &mut [u8]) {
data[i + 0] = r;
}
}
/// A `VecLike` that only tracks whether or not something was ever pushed to it.
pub struct ForgetfulSink {
empty: bool,
}
impl ForgetfulSink {
pub fn new() -> ForgetfulSink {
ForgetfulSink {
empty: true,
}
}
pub fn is_empty(&self) -> bool {
self.empty
}
}
impl<T> VecLike<T> for ForgetfulSink {
#[inline]
fn vec_len(&self) -> usize {
unreachable!()
}
#[inline]
fn vec_push(&mut self, _value: T) {
self.empty = false;
}
#[inline]
fn vec_slice_mut<'a>(&'a mut self, _start: usize, _end: usize) -> &'a mut [T] {
unreachable!()
}
}