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

Slightly optimise styled"" macro #88

Merged
merged 2 commits into from
Sep 8, 2024
Merged

Slightly optimise styled"" macro #88

merged 2 commits into from
Sep 8, 2024

Conversation

tecosaur
Copy link
Collaborator

@tecosaur tecosaur commented Sep 8, 2024

Does what it says on the tin: improves type stability a bit, and optimises the single-interpolation case.

This way, when interpolating, the type of the expression can be inferred
as an AnnotatedString, rather than a Union{String, AnnotatedString}.
When a single styled"{$face:$content}" form is used, this optimisation
makes the macroexpansion equivalent to handwritten code for this case,
as the annotatedstring_optimize! call is superfluous when there is only
one part.

While we're at it, we may as well make annotatedstring_optimize! more
efficient for the zero and one annotation cases.
@tecosaur tecosaur merged commit 03211c9 into main Sep 8, 2024
5 checks passed
@tecosaur tecosaur deleted the tiny-macro-opt branch September 8, 2024 13:42
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