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

Improve compaction of empty/blank TextComponents #764

Merged
merged 8 commits into from May 20, 2022

Conversation

Moulberry
Copy link
Contributor

@Moulberry Moulberry commented May 14, 2022

Improve compaction of empty/blank TextComponents

I believe that for a TextComponent comprised of only space characters (" "), TextColor and ITALIC stylings are redundant.
We can take advantage of this in order to further compact components.

Font and BOLD stylings also seem like candidates for removal, but afaik BOLD affects the advance of space character and in 1.19 Font will do so too.

Some examples

Removal of useless styling on blank components

Input: {"text":" ","color":"red"}
Before: {"text":" ","color":"red"}
After: {"text":" "}

Compaction of blank components (side effect of previous)

Input: {"text":"Hello ","extra":[{"color":"red","text":" "}]}
Before: {"text":"Hello ","extra":[{"color":"red","text":" "}]}
After: {"text":"Hello "}

#Removal of empty children, regardless of style

Input: {"text":"Hello ","color":"red","extra":[{"strikethrough":true,"text":""}]}
Before: {"text":"Hello ","color":"red","extra":[{"strikethrough":true,"text":""}]}
After: {"text":"Hello ","color":"red"}

Copy link
Member

@zml2008 zml2008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some tests for this as well?

rebase needed as well, but that can happen with other changes

@Moulberry
Copy link
Contributor Author

Last commit was supposed to say: Use optimized instead of self
It also fixed checkstyle errors

@zml2008 zml2008 added this to the 4.11.0 milestone May 15, 2022
@zml2008 zml2008 self-assigned this May 20, 2022
@zml2008 zml2008 merged commit e5135e0 into KyoriPowered:main/4 May 20, 2022
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.

None yet

2 participants