diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/msgthr.rb | 2 | ||||
-rw-r--r-- | lib/msgthr/container.rb | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/msgthr.rb b/lib/msgthr.rb index bf4b14e..8619c62 100644 --- a/lib/msgthr.rb +++ b/lib/msgthr.rb @@ -183,7 +183,7 @@ class Msgthr end # set parent of this message to be the last element in refs - if prev + if prev && !cur.has_descendent(prev) prev.add_child(cur) yield(prev, cur) if block_given? end diff --git a/lib/msgthr/container.rb b/lib/msgthr/container.rb index fbff719..256033b 100644 --- a/lib/msgthr/container.rb +++ b/lib/msgthr/container.rb @@ -64,9 +64,10 @@ class Msgthr::Container end def has_descendent(child) # :nodoc: - seen = Hash.new(0) + seen = {} while child - return true if self == child || (seen[child] += 1) != 0 + return true if self == child || seen[child] + seen[child] = true child = child.parent end false |