stylo: Refactor nsTArray sugar and remove unused import

This commit is contained in:
Emilio Cobos Álvarez 2016-06-01 13:44:38 +02:00
parent decf8c40f7
commit 33829b470a
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 11 additions and 5 deletions

View file

@ -32,19 +32,25 @@ impl<T> nsTArray<T> {
self.header().mLength
}
#[inline]
unsafe fn slice_begin(&self) -> *mut T {
debug_assert!(!self.mBuffer.is_null());
(self.mBuffer as *const nsTArrayHeader).offset(1) as *mut _
}
#[inline]
fn ptr_at_mut(&mut self, index: u32) -> *mut T {
debug_assert!(index <= self.len());
unsafe {
let slice_begin = (self.mBuffer as *const nsTArrayHeader).offset(1) as *mut T;
slice_begin.offset(index as isize)
self.slice_begin().offset(index as isize)
}
}
#[inline]
fn ptr_at(&self, index: u32) -> *const T {
debug_assert!(index <= self.len());
unsafe {
let slice_begin = (self.mBuffer as *const nsTArrayHeader).offset(1) as *const T;
slice_begin.offset(index as isize)
self.slice_begin().offset(index as isize)
}
}
}

View file

@ -20,7 +20,7 @@ use gecko_bindings::bindings::{Gecko_CopyMozBindingFrom, Gecko_CopyListStyleType
use gecko_bindings::bindings::{Gecko_SetMozBinding, Gecko_SetListStyleType};
use gecko_bindings::bindings::{Gecko_SetNullImageValue, Gecko_SetGradientImageValue};
use gecko_bindings::bindings::{Gecko_CreateGradient};
use gecko_bindings::bindings::{Gecko_SetGradientStop, Gecko_CopyImageValueFrom};
use gecko_bindings::bindings::{Gecko_CopyImageValueFrom};
use gecko_bindings::structs;
use glue::ArcHelpers;
use std::fmt::{self, Debug};