diff options
author | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-06-01 13:44:38 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-06-01 14:07:04 +0200 |
commit | 33829b470afe4503660799e407e60e2ee460ea91 (patch) | |
tree | e9b3f4f66d6230b93b1569a91706401970d8703f | |
parent | decf8c40f7ae342b9c9c1eba845feb40e0d4f4c5 (diff) | |
download | servo-33829b470afe4503660799e407e60e2ee460ea91.tar.gz servo-33829b470afe4503660799e407e60e2ee460ea91.zip |
stylo: Refactor nsTArray sugar and remove unused import
-rw-r--r-- | ports/geckolib/gecko_bindings/sugar/ns_t_array.rs | 14 | ||||
-rw-r--r-- | ports/geckolib/properties.mako.rs | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/ports/geckolib/gecko_bindings/sugar/ns_t_array.rs b/ports/geckolib/gecko_bindings/sugar/ns_t_array.rs index 795b045136f..6ea27d01a8d 100644 --- a/ports/geckolib/gecko_bindings/sugar/ns_t_array.rs +++ b/ports/geckolib/gecko_bindings/sugar/ns_t_array.rs @@ -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) } } } diff --git a/ports/geckolib/properties.mako.rs b/ports/geckolib/properties.mako.rs index 9282750d074..1a7fdb67c16 100644 --- a/ports/geckolib/properties.mako.rs +++ b/ports/geckolib/properties.mako.rs @@ -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}; |