From 33829b470afe4503660799e407e60e2ee460ea91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 1 Jun 2016 13:44:38 +0200 Subject: [PATCH] stylo: Refactor nsTArray sugar and remove unused import --- ports/geckolib/gecko_bindings/sugar/ns_t_array.rs | 14 ++++++++++---- 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 nsTArray { 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};