mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-03 18:29:09 +00:00
Also wrap langtype::Type::Struct in an Rc
This makes copying such types much cheaper and will allow us to intern common struct types in the future too. This further drops the sample cost for langtype.rs from ~6.6% down to 4.0%. We are now also able to share/intern common struct types. Before: ``` Time (mean ± σ): 1.073 s ± 0.021 s [User: 0.759 s, System: 0.215 s] Range (min … max): 1.034 s … 1.105 s 10 runs allocations: 3074261 ``` After: ``` Time (mean ± σ): 1.034 s ± 0.026 s [User: 0.733 s, System: 0.201 s] Range (min … max): 1.000 s … 1.078 s 10 runs allocations: 2917476 ```
This commit is contained in:
parent
efdecf0a13
commit
69c68b22b2
29 changed files with 302 additions and 259 deletions
|
@ -153,9 +153,9 @@ impl CompilationResult {
|
|||
|
||||
fn convert_type(py: Python<'_>, ty: &Type) -> Option<(String, PyObject)> {
|
||||
match ty {
|
||||
Type::Struct { fields, name: Some(name), node: Some(_), .. } => {
|
||||
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
|
||||
let struct_instance = PyStruct::from(slint_interpreter::Struct::from_iter(
|
||||
fields.iter().map(|(name, field_type)| {
|
||||
s.fields.iter().map(|(name, field_type)| {
|
||||
(
|
||||
name.to_string(),
|
||||
slint_interpreter::default_value_for_type(field_type),
|
||||
|
@ -163,7 +163,10 @@ impl CompilationResult {
|
|||
}),
|
||||
));
|
||||
|
||||
return Some((name.to_string(), struct_instance.into_py(py)));
|
||||
return Some((
|
||||
s.name.as_ref().unwrap().to_string(),
|
||||
struct_instance.into_py(py),
|
||||
));
|
||||
}
|
||||
Type::Enumeration(_en) => {
|
||||
// TODO
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue