Permalink
Browse files

Another bloom filter optimization - dont bother checking filter if it…

… is known to be empty
  • Loading branch information...
1 parent 2f5a858 commit 24e382eb8c1760803a4d7fc1638874963b2f0763 @josharnold52 josharnold52 committed Oct 21, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/main/scala/com/codecommit/antixml/Group.scala
@@ -362,10 +362,12 @@ class Group[+A <: Node] private[antixml] (private[antixml] val nodes: VectorCase
}
/** If true this group may contain an element with the given name as one of its children (recursively). */
- def matches(elementName: String) = bloomFilter contains elementName
+ def matches(elementName: String) =
+ if (bloomFilter eq Group.emptyBloomFilter) false else bloomFilter contains elementName
/** Same as `matches(String)`, but works with hashes created by Group.bloomFilterHash. */
- private[antixml] def matches(hash: BloomFilter.Hash) = bloomFilter containsHash hash
+ private[antixml] def matches(hash: BloomFilter.Hash) =
+ if (bloomFilter eq Group.emptyBloomFilter) false else bloomFilter containsHash hash
}
/**

0 comments on commit 24e382e

Please sign in to comment.