Use SmolStr in FamilyOwned instead of String
This commit is contained in:
parent
7c25fcb7ae
commit
caa214a755
2 changed files with 5 additions and 6 deletions
|
|
@ -21,6 +21,7 @@ rangemap = "1.4.0"
|
||||||
rustc-hash = { version = "1.1.0", default-features = false }
|
rustc-hash = { version = "1.1.0", default-features = false }
|
||||||
rustybuzz = { version = "0.14", default-features = false, features = ["libm"] }
|
rustybuzz = { version = "0.14", default-features = false, features = ["libm"] }
|
||||||
self_cell = "1.0.1"
|
self_cell = "1.0.1"
|
||||||
|
smol_str = { version = "0.2.2", default-features = false }
|
||||||
swash = { version = "0.1.17", optional = true }
|
swash = { version = "0.1.17", optional = true }
|
||||||
syntect = { version = "5.1.0", optional = true }
|
syntect = { version = "5.1.0", optional = true }
|
||||||
sys-locale = { version = "0.3.1", optional = true }
|
sys-locale = { version = "0.3.1", optional = true }
|
||||||
|
|
|
||||||
10
src/attrs.rs
10
src/attrs.rs
|
|
@ -1,12 +1,10 @@
|
||||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
use alloc::{
|
use alloc::vec::Vec;
|
||||||
string::{String, ToString},
|
|
||||||
vec::Vec,
|
|
||||||
};
|
|
||||||
use core::ops::Range;
|
use core::ops::Range;
|
||||||
use rangemap::RangeMap;
|
use rangemap::RangeMap;
|
||||||
|
use smol_str::SmolStr;
|
||||||
|
|
||||||
use crate::{CacheKeyFlags, Metrics};
|
use crate::{CacheKeyFlags, Metrics};
|
||||||
|
|
||||||
|
|
@ -69,7 +67,7 @@ impl Color {
|
||||||
/// An owned version of [`Family`]
|
/// An owned version of [`Family`]
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||||
pub enum FamilyOwned {
|
pub enum FamilyOwned {
|
||||||
Name(String),
|
Name(SmolStr),
|
||||||
Serif,
|
Serif,
|
||||||
SansSerif,
|
SansSerif,
|
||||||
Cursive,
|
Cursive,
|
||||||
|
|
@ -80,7 +78,7 @@ pub enum FamilyOwned {
|
||||||
impl FamilyOwned {
|
impl FamilyOwned {
|
||||||
pub fn new(family: Family) -> Self {
|
pub fn new(family: Family) -> Self {
|
||||||
match family {
|
match family {
|
||||||
Family::Name(name) => FamilyOwned::Name(name.to_string()),
|
Family::Name(name) => FamilyOwned::Name(SmolStr::from(name)),
|
||||||
Family::Serif => FamilyOwned::Serif,
|
Family::Serif => FamilyOwned::Serif,
|
||||||
Family::SansSerif => FamilyOwned::SansSerif,
|
Family::SansSerif => FamilyOwned::SansSerif,
|
||||||
Family::Cursive => FamilyOwned::Cursive,
|
Family::Cursive => FamilyOwned::Cursive,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue