Conversation
…n EmitTag In EmitTag, the else branch was always a no-op: it is only reached when IsFormattedTag is false, so the assignment was x.HasFormattedParent <- x.HasFormattedParent. This dead code is removed. EmitTag now uses the already-computed name directly for formatted/script tag checks, avoiding two extra CurrentTagName() calls (each does ToString().Trim()). IsFormattedTag and IsScriptTag also have the redundant .ToLowerInvariant() removed: tag names are lowercased at read time in ConsTag via Char.ToLowerInvariant. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist, an AI assistant for this repository.
Summary
Three related code-quality improvements in
HtmlParser.fs:1. Dead code removed from
EmitTagThe
elsebranch:...was always a no-op. It is only reached when
IsFormattedTagisfalse, so the expression simplifies tox.HasFormattedParent <- x.HasFormattedParent || false=x.HasFormattedParent <- x.HasFormattedParent. Removed.2. Avoid re-computing
CurrentTagName()inEmitTagEmitTagalready computesname = x.CurrentTag.ToString().Trim()at line 191. The subsequentIsFormattedTagandIsScriptTagchecks were callingCurrentTagName()again (each does anotherToString().Trim()). The method now usesnamedirectly:3. Redundant
.ToLowerInvariant()removed fromIsFormattedTag/IsScriptTagTag names are lowercased at read time —
ConsTagappliesChar.ToLowerInvariantto every character (line 270). The.ToLowerInvariant()calls in the properties were therefore redundant and allocated an extra string on every check (including the many calls in thetokenisefunction, lines 461–606).Test Status
dotnet run --project build/build.fsproj -t RunTests— 292 + 489 + 2 tests, 0 failed