mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-11 14:28:42 +00:00
Bug 1630676 - Don't use transmute to create PaintOrder values. r=emilio
I checked that rustc optimises the code just as well as with the transmute. https://rust.godbolt.org/z/w6UJN4
This commit is contained in:
parent
40593d91fb
commit
26b6ee1d3a
@ -146,8 +146,13 @@ impl SVGPaintOrder {
|
||||
|
||||
/// Get variant of `paint-order`
|
||||
pub fn order_at(&self, pos: u8) -> PaintOrder {
|
||||
// Safe because PaintOrder covers all possible patterns.
|
||||
unsafe { std::mem::transmute((self.0 >> pos * PAINT_ORDER_SHIFT) & PAINT_ORDER_MASK) }
|
||||
match (self.0 >> pos * PAINT_ORDER_SHIFT) & PAINT_ORDER_MASK {
|
||||
0 => PaintOrder::Normal,
|
||||
1 => PaintOrder::Fill,
|
||||
2 => PaintOrder::Stroke,
|
||||
3 => PaintOrder::Markers,
|
||||
_ => unreachable!("this cannot happen"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user