mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
Don't use transmute to create PaintOrder values
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
57fe27a4ef
commit
5d6c5132c1
1 changed files with 7 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue