Blocked Clause Elimination.
769259
private void block() {
        final long steps = this.limits.simpSteps;
        assert this.level == 0;
        assert !this.config.plain;
        if (!this.config.block) { return; }
        if (this.config.blkwait >= this.stats.simplifications) { return; }
        assert this.simplifier == Simplifier.TOPSIMP;
        this.simplifier = Simplifier.BLOCK;
        updateCands();
        final long limit;
        if (this.stats.simplifications <= this.config.blkrtc) { limit = Long.MAX_VALUE; } else { limit = this.stats.steps + 10 * steps / sizePenalty(); }
        while (this.empty == null && !this.candsBlock.empty() && this.stats.steps++ < limit) {
            final int cand = this.candsBlock.top();
            final long priority = this.candsBlock.priority(cand);
            this.candsBlock.pop(cand);
            if (priority == 0 || !var(cand).free()) { continue; }
            blockLit(cand);
            blockLit(-cand);
        }
        assert this.schedule;
        this.schedule = false;
        assert this.simplifier == Simplifier.BLOCK;
        this.simplifier = Simplifier.TOPSIMP;
    }
978498
def merge_consecutive_filter_clauses(ir_blocks):
    """"""
    if not ir_blocks:
        return ir_blocks

    new_ir_blocks = [ir_blocks[0]]

    for block in ir_blocks[1:]:
        last_block = new_ir_blocks[-1]
        if isinstance(last_block, Filter) and isinstance(block, Filter):
            new_ir_blocks[-1] = Filter(
                BinaryComposition(u'&&', last_block.predicate, block.predicate))
        else:
            new_ir_blocks.append(block)

    return new_ir_blocks
96765
def block_anyfilter(parser, token):
    
    bits = token.contents.split()
    nodelist = parser.parse(('endblockanyfilter',))
    parser.delete_first_token()
    return BlockAnyFilterNode(nodelist, bits[1], *bits[2:])
84721
private QueryResultImpl eliminateDuplicates(QueryResultImpl result) {
        QueryResultImpl ret = new QueryResultImpl(result.getQuery());
        Set<QueryBindingImpl> distinctSet = new HashSet<>(result.getBindings());
        distinctSet.forEach(ret::add);
        return ret;
    }
1178956
static public void filterBlockedElements(List<Context> executionContexts) {
    for (Context context : executionContexts) {
      Model model = new Model(context.getModel());
      List<Edge> edges = model.getEdges();
      List<Vertex> vertices = model.getVertices();

      ListIterator<Edge> e_it = edges.listIterator();
      while (e_it.hasNext()) {
        Edge edge = e_it.next();
        if (edge.hasProperty("blocked") &&
            (boolean) edge.getProperty("blocked")) {
          e_it.remove();
        }
      }
      ListIterator<Vertex> v_it = vertices.listIterator();
      while (v_it.hasNext()) {
        Vertex vertex = v_it.next();
        if (vertex.hasProperty("blocked") &&
            (boolean) vertex.getProperty("blocked")) {
          e_it = edges.listIterator();
          while (e_it.hasNext()) {
            Edge e = e_it.next();
            if (e.getSourceVertex() == vertex) {
              e_it.remove();
            } else if (e.getTargetVertex() == vertex) {
              e_it.remove();
            }
          }
          v_it.remove();
        }
      }
      context.setModel(model.build());
    }
  }
414598
private void evaluateDeferredAfterMaskUpdate() {
    final Iterator<DeferredAction<M>> it = this.deferred.iterator();

    while (it.hasNext()) {
      final DeferredAction<M> d = it.next();

      /* is the current action still masked? */
      if (masks.stream().anyMatch(p -> p.test(d.metadata))) {
        continue;
      }

      it.remove();
      d.runnable.run();
    }
  }
575907
public void removeBadSplits(SplitCriterion criterion, double lastCheckRatio, double lastCheckSDR, double lastCheckE) {
        removeBadSplitNodes(criterion, this.root, lastCheckRatio, lastCheckSDR, lastCheckE);
    }
1350457
def _RemoveForemanRule(self):
    """"""
    if data_store.RelationalDBEnabled():
      data_store.REL_DB.RemoveForemanRule(hunt_id=self.session_id.Basename())
      return

    with aff4.FACTORY.Open(
        "aff4:/foreman", mode="rw", token=self.token) as foreman:
      aff4_rules = foreman.Get(foreman.Schema.RULES)
      aff4_rules = foreman.Schema.RULES(
          # Remove those rules which fire off this hunt id.
          [r for r in aff4_rules if r.hunt_id != self.session_id])
      foreman.Set(aff4_rules)
344479
boolean removeFilteredPolicy(String sec, String ptype, int fieldIndex, String... fieldValues) {
        boolean ruleRemoved = model.removeFilteredPolicy(sec, ptype, fieldIndex, fieldValues);
        if (!ruleRemoved) {
            return false;
        }

        if (adapter != null && autoSave) {
            try {
                adapter.removeFilteredPolicy(sec, ptype, fieldIndex, fieldValues);
            } catch (Error e) {
                if (!e.getMessage().equals("not implemented")) {
                    throw e;
                }
            }

            if (watcher != null) {
                // error intentionally ignored
                watcher.update();
            }
        }

        return true;
    }
1165017
private void addDiscriminatorClause(List<String> clauses, EntityType entityType) {
        if (((AbstractManagedType) entityType).isInherited()) {
            String discrColumn = ((AbstractManagedType) entityType).getDiscriminatorColumn();
            String discrValue = ((AbstractManagedType) entityType).getDiscriminatorValue();

            if (discrColumn != null && discrValue != null) {
                if (clauses != null && !clauses.isEmpty()) {
                    filtersQueue.add("AND");
                }

                FilterClause filterClause = new FilterClause(discrColumn, "=", discrValue, discrColumn);
                filtersQueue.add(filterClause);
            }
        }
    }
593699
private boolean find(Clause clause, char[] chars, int[] cursor) {
    int start = cursor[0];
    int end = cursor[1];
    while (end - start >= clause.minlen)
      if (matchClause(clause, chars, cursor))
        return true;
      else
        cursor[0] = ++start;
    return false;
  }
124923
public void blockTillTerminated() {
    while (!runState.compareAndSet(State.IDLE, State.REMOVED)) {
      // wait and retry
      LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10));
      if (Thread.currentThread().isInterrupted()) {
        runState.set(State.REMOVED);
        return;
      }
    }
  }
942199
def exclude(*list, &block)
      @@exclusion << list.map { |s| "@#{s}".to_sym }
      @@exclusion.flatten!
      @@exclusion_block = block if block_given?
    end
1231181
def dead_code_elimination(graph, du, ud):
    
    for node in graph.rpo:
        for i, ins in node.get_loc_with_ins():
            reg = ins.get_lhs()
            if reg is not None:
                # If the definition is not used, we check that the instruction
                # has no side effect. If there is one and this is a call, we
                # remove only the unused defined variable. else, this is
                # something like an array access, so we do nothing.
                # Otherwise (no side effect) we can remove the instruction from
                # the node.
                if (reg, i) not in du:
                    if ins.is_call():
                        ins.remove_defined_var()
                    elif ins.has_side_effect():
                        continue
                    else:
                        # We can delete the instruction. First update the DU
                        # chain of the variables used by the instruction to
                        # `let them know` that they are not used anymore by the
                        # deleted instruction.
                        # Then remove the instruction.
                        update_chain(graph, i, du, ud)
                        graph.remove_ins(i)
1172090
public static boolean restrictQueryExecution(String sql) {
		String[] restrictions = { "delete", "truncate", "update", "drop", "alter" };
		if (sql != null) {
			sql = sql.toLowerCase();
			for (String restriction : restrictions) {
				if (sql.startsWith(restriction)) {
					return true;
				}
				String regex = "\\s+" + restriction + "\\s+";
				Pattern pattern = Pattern.compile(regex);
				Matcher matcher = pattern.matcher(sql);
				if (matcher.find()) {
					return true;
				}
			}
		}
		return false;
	}
398196
protected function _cleanClause($clause) {
        $clause = trim($clause);
        while ($clause[0] === '(' && $clause[strlen($clause)-1] === ')') {
            $clause = substr($clause, 1, -1);
        }
        return $clause;
    }
957231
def _rt_members_delete(self, element, statement):
        """"""
        removals = self.vparser.parse(statement, None)
        for member in removals:
            if member in element.members:
                del element.members[member]