Skip to content

Conversation

@jviide
Copy link
Collaborator

@jviide jviide commented Aug 13, 2019

This pull request modifies how the h functions are called (in the non-mini build) in order to track whether the element evaluated by h is static. When we talk about static elements in this context we mean elements whose tag or props are not in any way based on dynamic values. Text nodes are static if their text is not based on a dynamic value.

In h function calls made by HTM this will be a number. The number's two lowest bits are used to signal the following things:

  • If the lowest bit is set it means that the element that h is currently evaluating is static. The element's descendants may or may not be static.
  • If the second-to-lowest bit is set it means that all the element's descendants are static. The element itself may or may not be static.

In practice this means that h's this will be 0b00 when the element itself and one or more of its descendants is based on dynamic values. Conversely, this will be 0b11 when the element itself and all of its (zero or more) descendants are static. When the element itself is static but has dynamic descendants this will be 0b01, and when the element itself is dynamic but all of its (zero or more) descendants are static this will be 0b10.

This pull request also adds some rudimentary tests for statics tracking. The size of the Brotli-compressed htm.module.js.br increases by 24 bytes (596 B -> 620 B). The highest results in the "usage" benchmark are less than 2% lower compared to the master branch's highest results.

@jviide
Copy link
Collaborator Author

jviide commented Aug 15, 2019

Closing in favor of #117.

@jviide jviide closed this Aug 15, 2019
@jviide jviide deleted the statics-tracking branch August 15, 2019 13:10
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.

1 participant