From d6aec6aa1637c09593221b1abc214c53e126aa4b Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Sat, 12 Jul 2014 00:20:19 +0200 Subject: [PATCH] Compare nodes in on_path instead of indexes. This saves some code and effectively does the same thing. --- lib/oga/xpath/evaluator.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/oga/xpath/evaluator.rb b/lib/oga/xpath/evaluator.rb index 3c83dfe..26b77ab 100644 --- a/lib/oga/xpath/evaluator.rb +++ b/lib/oga/xpath/evaluator.rb @@ -54,12 +54,12 @@ module Oga end def on_path(node) - last_index = node.children.length - 1 + last_node = node.children[-1] - node.children.each_with_index do |test, index| + node.children.each do |test| process(test) - if index < last_index and !@stack.empty? + if test != last_node and !@stack.empty? swap_context end end