aboutsummaryrefslogtreecommitdiffstats
path: root/components/gfx/font.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-09-09 00:05:17 -0600
committerbors-servo <metajack+bors@gmail.com>2015-09-09 00:05:17 -0600
commitbe9a9ffda10fa2c50b13f79dabd49255f29f12f6 (patch)
tree9622df47c5446e93def3e0012de97e31bc188778 /components/gfx/font.rs
parent83972196600f04e817ddb53fda18142778905307 (diff)
parent94dec69247504a976cfa61495da759286160abec (diff)
downloadservo-be9a9ffda10fa2c50b13f79dabd49255f29f12f6.tar.gz
servo-be9a9ffda10fa2c50b13f79dabd49255f29f12f6.zip
Auto merge of #7523 - eefriedman:unnecessary-unsafe, r=SimonSapin
Fix up some unnecessary uses of `unsafe`. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7523) <!-- Reviewable:end -->
Diffstat (limited to 'components/gfx/font.rs')
-rw-r--r--components/gfx/font.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/components/gfx/font.rs b/components/gfx/font.rs
index 6fffb845106..b1765e8ae2c 100644
--- a/components/gfx/font.rs
+++ b/components/gfx/font.rs
@@ -6,9 +6,8 @@ use euclid::{Point2D, Rect, Size2D};
use smallvec::SmallVec;
use std::borrow::ToOwned;
use std::cell::RefCell;
-use std::mem;
use std::rc::Rc;
-use std::slice;
+use std::str;
use std::sync::Arc;
use style::computed_values::{font_stretch, font_variant, font_weight};
use style::properties::style_structs::Font as FontStyle;
@@ -56,12 +55,11 @@ pub trait FontTableTagConversions {
impl FontTableTagConversions for FontTableTag {
fn tag_to_str(&self) -> String {
- unsafe {
- let pointer = mem::transmute::<&u32, *const u8>(self);
- let mut bytes = slice::from_raw_parts(pointer, 4).to_vec();
- bytes.reverse();
- String::from_utf8_unchecked(bytes)
- }
+ let bytes = [(self >> 24) as u8,
+ (self >> 16) as u8,
+ (self >> 8) as u8,
+ (self >> 0) as u8];
+ str::from_utf8(&bytes).unwrap().to_owned()
}
}