mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Optimization: improve expression inlining
If a property is only used once, we can inline it with a bigger threshold. But this require to first compute the use, and then do the inlining while adjusting the usages
This commit is contained in:
parent
4de03fba5b
commit
5f77808d1c
7 changed files with 128 additions and 55 deletions
|
@ -1912,7 +1912,7 @@ fn generate_sub_component(
|
|||
|
||||
let mut properties_init_code = Vec::new();
|
||||
for (prop, expression) in &component.property_init {
|
||||
if expression.use_count.get() > 0 {
|
||||
if expression.use_count.get() > 0 && component.prop_used(prop) {
|
||||
handle_property_init(prop, expression, &mut properties_init_code, &ctx)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -995,22 +995,15 @@ fn generate_sub_component(
|
|||
}
|
||||
|
||||
for (prop, expression) in &component.property_init {
|
||||
if expression.use_count.get() > 0 {
|
||||
if expression.use_count.get() > 0 && component.prop_used(prop) {
|
||||
handle_property_init(prop, expression, &mut init, &ctx)
|
||||
}
|
||||
}
|
||||
for prop in &component.const_properties {
|
||||
if let llr::PropertyReference::Local { property_index, sub_component_path } = prop {
|
||||
let mut sc = component;
|
||||
for i in sub_component_path {
|
||||
sc = &sc.sub_components[*i].ty;
|
||||
}
|
||||
if sc.properties[*property_index].use_count.get() == 0 {
|
||||
continue;
|
||||
}
|
||||
if component.prop_used(prop) {
|
||||
let rust_property = access_member(prop, &ctx).unwrap();
|
||||
init.push(quote!(#rust_property.set_constant();))
|
||||
}
|
||||
let rust_property = access_member(prop, &ctx).unwrap();
|
||||
init.push(quote!(#rust_property.set_constant();))
|
||||
}
|
||||
|
||||
let parent_component_type = parent_ctx.iter().map(|parent| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue