Skip to content

improve nested attributed types & add more html tuples#98

Merged
sliemeobn merged 7 commits intoelementary-swift:mainfrom
erikbdev:main
Mar 26, 2026
Merged

improve nested attributed types & add more html tuples#98
sliemeobn merged 7 commits intoelementary-swift:mainfrom
erikbdev:main

Conversation

@erikbdev
Copy link
Copy Markdown
Contributor

This requests adds more tuples for OS that do not support parameter packs (embedded). I have also improved nested _AttributedElement, which should improve typed compilations.

// The following type would previously be
// _AttributedElement<_AttributedElement<_AttributedElement<HTMLElement<HTMLTag.p>, HTMLEmpty>>>>
p { }
  .attribute(.class("container check"))
  .attribute(.style(["color": "green"])
  .attribute([])

// With the changes, the type is now:
// _AttributedElement<HTMLElement<HTMLTag.p>, HTMLEmpty>>

If there are any questions feel free to let me know.

Use the same array of the original attributes instead of wrapping the html content on every attributes function call.
@erikbdev erikbdev changed the title improve recursive types & add more html tuples improve attribute repeated types & add more html tuples Mar 25, 2026
@sliemeobn
Copy link
Copy Markdown
Collaborator

thanks for this!

I wonder if we could extend the attribute handling to also work for HTMLElement and HTMLVoidElement?
It could be cool to define an internal protocol _Attributed or similar and implement the "in-place" extensions there (common extensions for all three attribute-holding elements)

wdyt?

@erikbdev
Copy link
Copy Markdown
Contributor Author

erikbdev commented Mar 26, 2026

I wonder if we could extend the attribute handling to also work for HTMLElement and HTMLVoidElement?

Is the current implementation not working for HTMLElemnent and HTMLVoidElement? Both of these structs extend the HTML protocol and require for Tag to extend Attributes.Global.

Edit: nevermind, I get what you mean. Will work on it right now.

@sliemeobn
Copy link
Copy Markdown
Collaborator

nice! I ran the benchmarks, looking good!

----------------------------------------------------------------------------------------------------------------------------
render merged attributes metrics
----------------------------------------------------------------------------------------------------------------------------

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│         Time (wall clock) (ns) *         │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │     863 │     930 │     947 │     963 │     983 │    1123 │    3782 │    4920 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│               Current_run                │     715 │     786 │     802 │     818 │     838 │     982 │    3066 │    5747 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                    Δ                     │    -148 │    -144 │    -145 │    -145 │    -145 │    -141 │    -716 │     827 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │      17 │      15 │      15 │      15 │      15 │      13 │      19 │     827 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│          Throughput (# / s) (K)          │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │    1159 │    1076 │    1057 │    1039 │    1018 │     891 │     264 │    4920 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│               Current_run                │    1398 │    1273 │    1247 │    1222 │    1194 │    1019 │     326 │    5747 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                    Δ                     │     239 │     197 │     190 │     183 │     176 │     128 │      62 │     827 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │      21 │      18 │      18 │      18 │      17 │      14 │      23 │     827 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│             Malloc (total) *             │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │       9 │       9 │       9 │       9 │       9 │       9 │       9 │    4920 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│               Current_run                │       8 │       8 │       8 │       8 │       8 │       8 │       8 │    5747 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                    Δ                     │      -1 │      -1 │      -1 │      -1 │      -1 │      -1 │      -1 │     827 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │      11 │      11 │      11 │      11 │      11 │      11 │      11 │     827 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│            Instructions (K) *            │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │      25 │      25 │      25 │      25 │      25 │      25 │      26 │    4920 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│               Current_run                │      21 │      21 │      21 │      21 │      21 │      21 │      22 │    5747 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                    Δ                     │      -4 │      -4 │      -4 │      -4 │      -4 │      -4 │      -4 │     827 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │      16 │      16 │      16 │      16 │      16 │      16 │      15 │     827 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

@sliemeobn sliemeobn changed the title improve attribute repeated types & add more html tuples improve nested attributed types & add more html tuples Mar 26, 2026
@sliemeobn sliemeobn merged commit f175625 into elementary-swift:main Mar 26, 2026
10 checks passed
@sliemeobn
Copy link
Copy Markdown
Collaborator

@erikbdev FYI, I just merged #99 to still support up to 12 types in the build without introducing new tuple types. I think this is the better tradeoff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants