Activates the cache for the given right-hand operand. Re-initializes the hash set if the operand has changed since the previous call; dismisses the cache permanently if the previous cache had no hits and the right-hand operand was not fully consumed (no reuse benefit). @param val right-hand operand
(final Value val, final Iter ir)
| 45 | * a non-cached comparison |
| 46 | */ |
| 47 | boolean active(final Value val, final Iter ir) { |
| 48 | // check if caching was dismissed |
| 49 | if(set == null) return false; |
| 50 | |
| 51 | // operand changed: dismiss only if cache was unused (no hits AND not fully built) |
| 52 | if(value != val) { |
| 53 | if(!hit && iter != null) { |
| 54 | set = null; |
| 55 | value = null; |
| 56 | iter = null; |
| 57 | return false; |
| 58 | } |
| 59 | init(); |
| 60 | value = val; |
| 61 | iter = ir; |
| 62 | hit = false; |
| 63 | } |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Creates a fresh empty hash set. |