From ecdeeacd767ec974e7cf2306f30d62bf7c3120b8 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 7 May 2015 23:03:03 +0200 Subject: [PATCH] Use Symbol#equal? instead of Symbol#== At least on JRuby and Rubinius this can be quite a bit faster. On MRI the difference is not really significant. --- lib/oga/css/parser.rll | 2 +- lib/oga/xml/document.rb | 2 +- lib/oga/xpath/evaluator.rb | 2 +- lib/oga/xpath/parser.rll | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/oga/css/parser.rll b/lib/oga/css/parser.rll index 1b22ae4..83d9651 100644 --- a/lib/oga/css/parser.rll +++ b/lib/oga/css/parser.rll @@ -668,7 +668,7 @@ even # @return [TrueClass|FalseClass] # def int_node?(node) - return node.type == :int + return node.type.equal?(:int) end ## diff --git a/lib/oga/xml/document.rb b/lib/oga/xml/document.rb index 053b67d..79143e9 100644 --- a/lib/oga/xml/document.rb +++ b/lib/oga/xml/document.rb @@ -83,7 +83,7 @@ module Oga # @return [TrueClass|FalseClass] # def html? - return type == :html + return type.equal?(:html) end ## diff --git a/lib/oga/xpath/evaluator.rb b/lib/oga/xpath/evaluator.rb index 39d06c7..0e9a40c 100644 --- a/lib/oga/xpath/evaluator.rb +++ b/lib/oga/xpath/evaluator.rb @@ -1640,7 +1640,7 @@ module Oga def node_matches?(xml_node, ast_node) ns, name = *ast_node.children - if ast_node.type == :type_test + if ast_node.type.equal?(:type_test) return type_matches?(xml_node, ast_node) end diff --git a/lib/oga/xpath/parser.rll b/lib/oga/xpath/parser.rll index 9aa6b65..4b97f3e 100644 --- a/lib/oga/xpath/parser.rll +++ b/lib/oga/xpath/parser.rll @@ -134,7 +134,7 @@ path_step args = val[1][1] pred = val[1][2] - if type == :test + if type.equal?(:test) # Whenever a bare test is used (e.g. just "A") this actually means # "child::A". Handling this on parser level is the easiest. if args