Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Optimise DASH manifest generation #870

Merged
merged 1 commit into from
Jan 13, 2025
Merged

Conversation

absidue
Copy link
Collaborator

@absidue absidue commented Jan 12, 2025

This pull request introduces various optimisations to DASH manifest generation. I have checked that the generated XML is still the same as before.

  1. It turns out that the JSX transform only checks the first letter in the tag name to decided if it is an element (lower case) or a component/function (upper case). So I decided to change the tag names to be the same as their actual names but with the first letter changed to lower case, that way we can simplify the code in normalizeTag name to just change the first character to upper case.
  2. For text nodes we currently create a TEXT_ELEMENT wrapper object and then give that TEXT_ELEMENT object special treatment in renderElementToString to treat it as a string. As our target is just a string and not some DOM like environment, I simplified it to just pass through the string and then to give it special treatment if it is a string. That means the code is simpler and we are creating less temporary objects.
  3. I simplified the property handling from using .filter(), .map(), checking the .length, then calling .join() and appending it to the element string to a for-of loop with an if that appends directly to the element string.

The DASH manifest generation still isn't ideal (parser structure -> streaming info structure -> jsx elements tree -> string) but these changes will at least improve it a bit, without major refactoring.

@absidue absidue requested a review from LuanRT January 12, 2025 17:15
@LuanRT LuanRT merged commit 1a3d663 into LuanRT:main Jan 13, 2025
4 checks passed
@absidue absidue deleted the optimise-dash branch January 13, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants