aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-11-18 22:01:40 -0800
committerPatrick Walton <pcwalton@mimiga.net>2012-11-18 22:01:40 -0800
commitc31bd435700446dd13d4f34f7715aa5476d6eba2 (patch)
tree3ce6f3161cbac2530e171474f2b0712207435a63
parent0c72f6ded8e580d8ded70eb6fed014d5b0e42826 (diff)
downloadservo-c31bd435700446dd13d4f34f7715aa5476d6eba2.tar.gz
servo-c31bd435700446dd13d4f34f7715aa5476d6eba2.zip
css, gfx, sub: Eliminate many copies
m---------src/rust-css0
-rw-r--r--src/servo-gfx/quartz/font.rs26
-rw-r--r--src/servo/css/select_handler.rs4
3 files changed, 15 insertions, 15 deletions
diff --git a/src/rust-css b/src/rust-css
-Subproject b1ac22d98de7c6e622709ebd3ae2bd63a762b2b
+Subproject f5ebbe2787cec856ce52c1aabec28e30939b9b3
diff --git a/src/servo-gfx/quartz/font.rs b/src/servo-gfx/quartz/font.rs
index 8951e46d6f9..2ef54205bda 100644
--- a/src/servo-gfx/quartz/font.rs
+++ b/src/servo-gfx/quartz/font.rs
@@ -146,15 +146,13 @@ pub impl QuartzFontHandle : FontHandleMethods {
}
fn glyph_index(codepoint: char) -> Option<GlyphIndex> {
- let characters: ~[UniChar] = ~[codepoint as UniChar];
- let glyphs: ~[mut CGGlyph] = ~[mut 0 as CGGlyph];
+ let characters: [UniChar * 1] = [codepoint as UniChar];
+ let glyphs: [mut CGGlyph * 1] = [mut 0 as CGGlyph];
let count: CFIndex = 1;
- let result = do vec::as_imm_buf(characters) |character_buf, _l| {
- do vec::as_imm_buf(glyphs) |glyph_buf, _l| {
- self.ctfont.get_glyphs_for_characters(character_buf, glyph_buf, count)
- }
- };
+ let result = self.ctfont.get_glyphs_for_characters(ptr::to_unsafe_ptr(&characters[0]),
+ ptr::to_unsafe_ptr(&glyphs[0]),
+ count);
if !result {
// No glyph for this character
@@ -166,12 +164,14 @@ pub impl QuartzFontHandle : FontHandleMethods {
}
fn glyph_h_advance(glyph: GlyphIndex) -> Option<FractionalPixel> {
- let glyphs = ~[glyph as CGGlyph];
- let advance = do vec::as_imm_buf(glyphs) |glyph_buf, _l| {
- self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation, glyph_buf, ptr::null(), 1)
- };
-
- return Some(advance as FractionalPixel);
+ let glyphs = [glyph as CGGlyph];
+ unsafe {
+ let advance = self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation,
+ ptr::to_unsafe_ptr(&glyphs[0]),
+ ptr::null(),
+ 1);
+ return Some(advance as FractionalPixel);
+ }
}
fn get_metrics() -> FontMetrics {
diff --git a/src/servo/css/select_handler.rs b/src/servo/css/select_handler.rs
index 179b7cc9501..ed35938ed59 100644
--- a/src/servo/css/select_handler.rs
+++ b/src/servo/css/select_handler.rs
@@ -71,10 +71,10 @@ impl NodeSelectHandler: SelectHandler<Node> {
self.parent_node(node).is_none()
}
- fn node_id(node: &Node) -> Option<~str> {
+ fn with_node_id<R>(node: &Node, f: &fn(Option<&str>) -> R) -> R {
do node.read |data| {
match *data.kind {
- Element(ref data) => data.get_attr("id"),
+ Element(ref data) => data.with_attr("id", f),
_ => fail ~"attempting to style non-element node"
}
}