Use triomphe instead of servo_arc

That's a fork of servo_arc which is updated more recently
This commit is contained in:
Olivier Goffart 2020-07-17 17:13:51 +02:00
parent 2f0718bffa
commit e7d2c35a07
3 changed files with 16 additions and 16 deletions

View file

@ -21,7 +21,7 @@ corelib_macro = { path = "../corelib_macro" }
winit = "0.22.1" winit = "0.22.1"
lyon = { version = "0.15.8" } lyon = { version = "0.15.8" }
euclid = "0.20.11" euclid = "0.20.11"
servo_arc = "0.1.1" #we need the Arc::from_header_and_iter triomphe = "0.1.1"
once_cell = "1.4" once_cell = "1.4"
instant = { version = "0.1", features = [ "now" ] } instant = { version = "0.1", features = [ "now" ] }
derive_more = "0.99.5" derive_more = "0.99.5"

View file

@ -1,7 +1,7 @@
//! module for the SharedArray and related things //! module for the SharedArray and related things
use core::mem::MaybeUninit; use core::mem::MaybeUninit;
use servo_arc::ThinArc;
use std::{fmt::Debug, fmt::Display, ops::Deref}; use std::{fmt::Debug, fmt::Display, ops::Deref};
use triomphe::{Arc, HeaderWithLength, ThinArc};
#[derive(Clone)] #[derive(Clone)]
#[repr(C)] #[repr(C)]
@ -81,8 +81,8 @@ impl<T: Clone> SharedArray<T> {
let iter = PaddingFillingIter::new(len, item_iter); let iter = PaddingFillingIter::new(len, item_iter);
SharedArray { SharedArray {
inner: servo_arc::Arc::into_thin(servo_arc::Arc::from_header_and_iter( inner: Arc::into_thin(Arc::from_header_and_iter(
servo_arc::HeaderWithLength::new(len, iter.size_hint().0), HeaderWithLength::new(len, iter.size_hint().0),
iter, iter,
)), )),
} }
@ -110,8 +110,8 @@ impl<T: Clone + Copy + Default + Sized + 'static> StaticNull for T {
let null_iter = &mut std::iter::empty(); let null_iter = &mut std::iter::empty();
let iter = PaddingFillingIter::new(len, null_iter); let iter = PaddingFillingIter::new(len, null_iter);
servo_arc::Arc::into_thin(servo_arc::Arc::from_header_and_iter( Arc::into_thin(Arc::from_header_and_iter(
servo_arc::HeaderWithLength::new(len, iter.size_hint().0), HeaderWithLength::new(len, iter.size_hint().0),
iter, iter,
)) ))
}); });

View file

@ -1,7 +1,7 @@
//! module for the SharedString and related things //! module for the SharedString and related things
use core::mem::MaybeUninit; use core::mem::MaybeUninit;
use servo_arc::ThinArc;
use std::{fmt::Debug, fmt::Display, ops::Deref}; use std::{fmt::Debug, fmt::Display, ops::Deref};
use triomphe::{Arc, HeaderWithLength, ThinArc};
/// The string type suitable for properties. It is shared meaning passing copies /// The string type suitable for properties. It is shared meaning passing copies
/// around will not allocate, and that different properties with the same string /// around will not allocate, and that different properties with the same string
@ -46,8 +46,8 @@ impl SharedString {
pub fn push_str(&mut self, x: &str) { pub fn push_str(&mut self, x: &str) {
let new_len = self.inner.header.header + x.len(); let new_len = self.inner.header.header + x.len();
if new_len + 1 < self.inner.slice.len() { if new_len + 1 < self.inner.slice.len() {
let mut arc = servo_arc::Arc::from_thin(self.inner.clone()); let mut arc = Arc::from_thin(self.inner.clone());
if let Some(inner) = servo_arc::Arc::get_mut(&mut arc) { if let Some(inner) = Arc::get_mut(&mut arc) {
unsafe { unsafe {
core::ptr::copy_nonoverlapping( core::ptr::copy_nonoverlapping(
x.as_ptr(), x.as_ptr(),
@ -91,7 +91,7 @@ impl SharedString {
return Some(MaybeUninit::new(0)); return Some(MaybeUninit::new(0));
} }
// I don't know if the compiler will be smart enough to exit the loop here. // I don't know if the compiler will be smart enough to exit the loop here.
// It would be nice if servo_arc::Arc would allow to leave uninitialized memory // It would be nice if triomphe::Arc would allow to leave uninitialized memory
Some(MaybeUninit::uninit()) Some(MaybeUninit::uninit())
} }
fn size_hint(&self) -> (usize, Option<usize>) { fn size_hint(&self) -> (usize, Option<usize>) {
@ -110,8 +110,8 @@ impl SharedString {
new_alloc, new_alloc,
}; };
self.inner = servo_arc::Arc::into_thin(servo_arc::Arc::from_header_and_iter( self.inner = Arc::into_thin(Arc::from_header_and_iter(
servo_arc::HeaderWithLength::new(new_len, new_alloc), HeaderWithLength::new(new_len, new_alloc),
iter, iter,
)); ));
} }
@ -129,8 +129,8 @@ impl Default for SharedString {
// Unfortunately, the Arc constructor is not const, so we must use a Lazy static for that // Unfortunately, the Arc constructor is not const, so we must use a Lazy static for that
static NULL: once_cell::sync::Lazy<ThinArc<usize, MaybeUninit<u8>>> = static NULL: once_cell::sync::Lazy<ThinArc<usize, MaybeUninit<u8>>> =
once_cell::sync::Lazy::new(|| { once_cell::sync::Lazy::new(|| {
servo_arc::Arc::into_thin(servo_arc::Arc::from_header_and_iter( Arc::into_thin(Arc::from_header_and_iter(
servo_arc::HeaderWithLength::new(0, core::mem::align_of::<usize>()), HeaderWithLength::new(0, core::mem::align_of::<usize>()),
[MaybeUninit::new(0); core::mem::align_of::<usize>()].iter().cloned(), [MaybeUninit::new(0); core::mem::align_of::<usize>()].iter().cloned(),
)) ))
}); });
@ -174,8 +174,8 @@ impl From<&str> for SharedString {
let iter = AddNullIter { str: value.as_bytes(), pos: 0 }; let iter = AddNullIter { str: value.as_bytes(), pos: 0 };
SharedString { SharedString {
inner: servo_arc::Arc::into_thin(servo_arc::Arc::from_header_and_iter( inner: Arc::into_thin(Arc::from_header_and_iter(
servo_arc::HeaderWithLength::new(value.len(), iter.size_hint().0), HeaderWithLength::new(value.len(), iter.size_hint().0),
iter, iter,
)), )),
} }