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

Feature/strippable text optimization #9182

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ivandrofly
Copy link
Member

Faster and better algorithm for Strippable Text.

Less allocations

Simplify and optimize logic for stripping text boundaries. Reduces redundant checks and improves maintainability by streamlining character parsing in the constructor.

Signed-off-by: Ivandro Jao <[email protected]>
Updated the assertions in the StrippableTextFontDontTouch test to reflect the correct expected values for Pre and StrippedText properties. This ensures the test aligns with the intended behavior and avoids false negatives.

Signed-off-by: Ivandro Jao <[email protected]>
@@ -57,9 +57,9 @@ public void StrippableTextItalic3()
public void StrippableTextFontDontTouch()
{
var st = new StrippableText("{MAN} Hi, how are you today!");
Assert.AreEqual("", st.Pre);
Assert.AreEqual("{", st.Pre);
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this test was wrong.

We should treat '{' as '[' When it hold hearing impaired word/sentence

Previously, the logic did not account for specific edge cases where the '>' character should not trigger stripping. This update adds a condition to ensure the behavior aligns with expected outcomes, preventing undesired alterations to the input.

Signed-off-by: Ivandro Jao <[email protected]>
Introduced a utility method to recognize ASS tags and updated related logic to filter unidentified tags accordingly. Expanded `HtmlUtil` with a set of known HTML tags to improve tag validation and prevent stripping valid structures.

Signed-off-by: Ivandro Jao <[email protected]>
Commented out unused closing tags in KnownHtmlTags to clean up the static set. Enhanced `IsKnownHtmlTag` to handle closing tags dynamically, improving flexibility for future use cases.

SubtitleEdit@657675f
Signed-off-by: Ivandro Jao <[email protected]>
Replaced case-insensitive comparison with StringComparison.Ordinal for closing tags to ensure consistent behavior. This improves clarity and aligns the implementation with best practices for string comparisons.

Signed-off-by: Ivandro Jao <[email protected]>
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