Remove uses of EcoString::inline

EcoString::inline can produce runtime panics if things are changed later. It should only be used if really necessary (because of const context)
This commit is contained in:
Laurenz 2023-12-28 13:58:03 +01:00
parent 67ead94cc2
commit 0c08022ffa
3 changed files with 7 additions and 22 deletions

View File

@ -837,13 +837,7 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream {
let field_dict = element.inherent_fields().clone().map(|field| {
let name = &field.name;
let field_ident = &field.ident;
let field_call = if name.len() > 15 {
quote! { ::ecow::EcoString::from(#name).into() }
} else {
quote! { ::ecow::EcoString::inline(#name).into() }
};
let field_call = quote! { ::ecow::EcoString::from(#name).into() };
quote! {
fields.insert(
#field_call,
@ -860,13 +854,7 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream {
.map(|field| {
let name = &field.name;
let field_ident = &field.ident;
let field_call = if name.len() > 15 {
quote! { ::ecow::EcoString::from(#name).into() }
} else {
quote! { ::ecow::EcoString::inline(#name).into() }
};
let field_call = quote! { ::ecow::EcoString::from(#name).into() };
if field.synthesized && field.default.is_some() {
quote! {
fields.insert(
@ -926,7 +914,7 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream {
quote! {
if let Some(label) = self.label() {
fields.insert(
::ecow::EcoString::inline("label").into(),
"label".into(),
#foundations::IntoValue::into_value(label)
);
}

View File

@ -695,11 +695,8 @@ impl Serialize for Content {
S: Serializer,
{
serializer.collect_map(
iter::once((
Str::from(EcoString::inline("func")),
self.func().name().into_value(),
))
.chain(self.fields()),
iter::once(("func".into(), self.func().name().into_value()))
.chain(self.fields()),
)
}
}
@ -736,7 +733,7 @@ impl PartialEq for SequenceElem {
impl Repr for SequenceElem {
fn repr(&self) -> EcoString {
if self.children.is_empty() {
EcoString::inline("[]")
"[]".into()
} else {
eco_format!(
"[{}]",

View File

@ -7,7 +7,7 @@ pub struct SpaceElem {}
impl Repr for SpaceElem {
fn repr(&self) -> EcoString {
EcoString::inline("[ ]")
"[ ]".into()
}
}