From 0298e7068c79a46aef6dc8256ccc25348d2bdf1d Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 7 May 2015 01:04:03 +0200 Subject: [PATCH] Don't use Namespace#to_s when matching namespaces This is a waste of time as it allocates a new String on every call. --- lib/oga/xpath/evaluator.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/oga/xpath/evaluator.rb b/lib/oga/xpath/evaluator.rb index 8892318..266f883 100644 --- a/lib/oga/xpath/evaluator.rb +++ b/lib/oga/xpath/evaluator.rb @@ -1702,7 +1702,9 @@ module Oga def namespace_matches?(xml_node, ns) return false unless xml_node.respond_to?(:namespace) - return ns == STAR ? true : xml_node.namespace.to_s == ns + return true if ns == STAR + + return xml_node.namespace && xml_node.namespace.name == ns end ##