servo: Merge #16987 - Using stack-allocated variable for font feature setting (from tictakk:ticbranch); r=emilio
authorMatthew <mkersey@uscupstate.edu>
Mon, 29 May 2017 09:58:43 -0500
changeset 409225 958633822c0969edd7796117e741984c13b29354
parent 409224 b89704b3bc199bc0f227d103532e187cf81a08e3
child 409226 4d8182ea2319cc481a3d74dded1dcd02d0fc48cb
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs16987, 16743
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #16987 - Using stack-allocated variable for font feature setting (from tictakk:ticbranch); r=emilio <!-- Please describe your changes on the following line: --> Using stack-allocated small vector instead of the previous vector<u8>. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #16743 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because this is an optimization <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 8dc787923020561fe033ae8e6efeccff5226c83e
servo/components/style/values/generics/mod.rs
--- a/servo/components/style/values/generics/mod.rs
+++ b/servo/components/style/values/generics/mod.rs
@@ -176,22 +176,22 @@ pub struct FontSettingTag<T> {
     /// The value
     pub value: T,
 }
 
 impl<T> OneOrMoreCommaSeparated for FontSettingTag<T> {}
 
 impl<T: ToCss> ToCss for FontSettingTag<T> {
     fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
-        use byteorder::{WriteBytesExt, BigEndian};
+        use byteorder::{BigEndian, ByteOrder};
         use cssparser::serialize_string;
         use std::str;
 
-        let mut raw: Vec<u8> = vec!();
-        raw.write_u32::<BigEndian>(self.tag).unwrap();
+        let mut raw = [0u8; 4];
+        BigEndian::write_u32(&mut raw, self.tag);
         serialize_string(str::from_utf8(&raw).unwrap_or_default(), dest)?;
 
         self.value.to_css(dest)
     }
 }
 
 impl<T: Parse> Parse for FontSettingTag<T> {
     /// https://www.w3.org/TR/css-fonts-3/#propdef-font-feature-settings
@@ -305,10 +305,8 @@ impl Parse for FontSettingTagFloat {
 }
 
 impl ToCss for FontSettingTagFloat {
     fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
         dest.write_str(" ")?;
         self.0.to_css(dest)
     }
 }
-
-