Skip to content

Commit

Permalink
perf: PermitScrubber#scrub checks node.element? before node.comment?
Browse files Browse the repository at this point in the history
Assuming elements are more common than comments, this is going to be
one less method call per node.
  • Loading branch information
flavorjones committed Aug 20, 2021
1 parent ab21d78 commit b1fe437
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,11 @@
## next / unreleased

* Slightly improve performance.

Assuming elements are more common than comments, make one less method call per node.

*Mike Dalessio*

## 1.4.1 / 2021-08-18

* Fix regression in v1.4.0 that did not pass comment nodes to the scrubber.
Expand Down
2 changes: 1 addition & 1 deletion lib/rails/html/scrubbers.rb
Expand Up @@ -68,7 +68,7 @@ def scrub(node)
end
return CONTINUE if skip_node?(node)

unless (node.comment? || node.element?) && keep_node?(node)
unless (node.element? || node.comment?) && keep_node?(node)
return STOP if scrub_node(node) == STOP
end

Expand Down

0 comments on commit b1fe437

Please sign in to comment.