style: Make quotes property representation allocate less.

Differential Revision: https://phabricator.services.mozilla.com/D10650
This commit is contained in:
Cameron McCormack 2018-11-06 23:03:33 +00:00 committed by Emilio Cobos Álvarez
parent 56fd3b786f
commit acf7b65f36
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 54 additions and 66 deletions

View file

@ -6,26 +6,30 @@
#[cfg(feature = "gecko")]
pub use values::specified::list::ListStyleType;
pub use values::specified::list::Quotes;
pub use values::specified::list::{QuotePair, Quotes};
use servo_arc::Arc;
use values::specified::list::QuotePair;
lazy_static! {
static ref INITIAL_QUOTES: Arc<Box<[QuotePair]>> = Arc::new(
vec![
QuotePair {
opening: "\u{201c}".to_owned().into_boxed_str(),
closing: "\u{201d}".to_owned().into_boxed_str(),
},
QuotePair {
opening: "\u{2018}".to_owned().into_boxed_str(),
closing: "\u{2019}".to_owned().into_boxed_str(),
},
].into_boxed_slice()
);
}
impl Quotes {
/// Initial value for `quotes`.
///
/// FIXME(emilio): This should ideally not allocate.
#[inline]
pub fn get_initial_value() -> Quotes {
Quotes(
vec![
(
"\u{201c}".to_owned().into_boxed_str(),
"\u{201d}".to_owned().into_boxed_str(),
),
(
"\u{2018}".to_owned().into_boxed_str(),
"\u{2019}".to_owned().into_boxed_str(),
),
]
.into_boxed_slice(),
)
Quotes(INITIAL_QUOTES.clone())
}
}