lib/rambling/trie/compressed_node.rb in rambling-trie-0.9.1 vs lib/rambling/trie/compressed_node.rb in rambling-trie-0.9.2

- old
+ new

@@ -27,12 +27,11 @@ # Returns all words that start with the specified characters. # @param [Array] chars the characters to look for in the trie. # @return [Array] all the words contained in the trie that start with the specified characters. def scan chars - node = chars.empty? ? self : closest_node(chars) - node.to_a + chars.empty? ? self : closest_node(chars) end # Always return `true` for a raw (compressed) node. # @return [Boolean] always true for a raw (compressed) node. def compressed? @@ -71,10 +70,10 @@ current_key = current_key chars.slice!(0) begin current_length += 1 - if (current_key && current_key.length == current_length) || chars.empty? + if current_key && (current_key.length == current_length || chars.empty?) return children_tree[current_key.to_sym].send method, chars end end while current_key && current_key[current_length] == chars.slice!(0) end