Skip to content

Commit b1fe437

Browse files
committed
perf: PermitScrubber#scrub checks node.element? before node.comment?
Assuming elements are more common than comments, this is going to be one less method call per node.
1 parent ab21d78 commit b1fe437

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## next / unreleased
2+
3+
* Slightly improve performance.
4+
5+
Assuming elements are more common than comments, make one less method call per node.
6+
7+
*Mike Dalessio*
8+
19
## 1.4.1 / 2021-08-18
210

311
* Fix regression in v1.4.0 that did not pass comment nodes to the scrubber.

lib/rails/html/scrubbers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def scrub(node)
6868
end
6969
return CONTINUE if skip_node?(node)
7070

71-
unless (node.comment? || node.element?) && keep_node?(node)
71+
unless (node.element? || node.comment?) && keep_node?(node)
7272
return STOP if scrub_node(node) == STOP
7373
end
7474

0 commit comments

Comments
 (0)