Extract common prefix from OR clause. This is beneficial because it reduces the amount
that needs to be checked for each branch. For example: {@code "ab|ac" => "a(b|c)"}.
557831
static Matcher extractPrefixFromOr(Matcher matcher) {
    if (matcher instanceof OrMatcher) {
      // Get the prefix for the first condition
      List<Matcher> matchers = matcher.<OrMatcher>as().matchers();
      if (matchers.isEmpty()) {
        return matcher;
      }
      Matcher prefix = PatternUtils.getPrefix(matchers.get(0));
      if (prefix.alwaysMatches()) {
        return matcher;
      }
      List<Matcher> ms = new ArrayList<>();
      ms.add(PatternUtils.getSuffix(matchers.get(0)));

      // Verify all OR conditions have the same prefix
      for (Matcher m : matchers.subList(1, matchers.size())) {
        Matcher p = PatternUtils.getPrefix(m);
        if (!prefix.equals(p)) {
          return matcher;
        }
        ms.add(PatternUtils.getSuffix(m));
      }

      return SeqMatcher.create(prefix, OrMatcher.create(ms));
    }
    return matcher;
  }
755486
private ComparableExpression extractComparableExpression(GDLParser.ComparisonElementContext element) {
    if(element.literal() != null) {
      return new Literal(getPropertyValue(element.literal()));
    } else if(element.propertyLookup() != null) {
      return buildPropertySelector(element.propertyLookup());
    } else {
      return new ElementSelector(element.Identifier().getText());
    }
  }
1247864
private Pair<String, String> extractParam(String part) {
        int eqInx = part.indexOf('=');
        String paramName;
        String paramValue;
        if (eqInx < 0) {
            paramName = part;
            paramValue = null;
        } else {
            paramName = part.substring(0, eqInx);
            paramValue = part.substring(eqInx + 1);
        }
        return Pair.create(paramName, paramValue);
    }
843720
boolean checkPrefix(char[] chars, int[] cursor) {
    if (prefix == null)
      return true;
    else
      return matchClause(prefix, chars, cursor);
  }
371747
def drop_prefix(strings):
    
    strings_without_extensions = [
        s.split(".", 2)[0] for s in strings
    ]

    if len(strings_without_extensions) == 1:
        return [os.path.basename(strings_without_extensions[0])]
    prefix_len = len(os.path.commonprefix(strings_without_extensions))
    result = [string[prefix_len:] for string in strings_without_extensions]
    if len(set(result)) != len(strings):
        # If these operations resulted in a collision, just return the original
        # strings.
        return strings
    return result
678618
@Override
  public ExprKraken getKeyExpr(String name)
  {
    if (name.equals(_column.getColumn().name())) {
      return getRight();
    }
    else {
      return null;
    }
  }
786698
private ExprKraken parseAndExpr()
  {
    // AndExpr oldAndExpr = _andExpr;
    AndExpr andExpr = new AndExpr();
    // _andExpr = andExpr;

    andExpr.add(parseNotExpr());

    while (true) {
      Token token = scanToken();

      switch (token) {
      case AND:
        andExpr.add(parseNotExpr());
        break;

      default:
        _token = token;

        // _andExpr = oldAndExpr;

        return andExpr.getSingleExpr();
      }
    }
  }
809941
private IndexExpression indexedExpression(List<IndexExpression> clause) {
        for (IndexExpression indexExpression : clause) {
            ByteBuffer columnName = indexExpression.column;
            if (indexedColumnName.equals(columnName)) {
                return indexExpression;
            }
        }
        return null;
    }
426964
public String findTypeWithMatchingNamespace(String prefix) {
    prefix = prefix + ".";
    // This must be sorted so that errors are deterministic, or we'll break integration tests.
    for (String name : getAllSortedTypeNames()) {
      if (name.startsWith(prefix)) {
        return name;
      }
    }
    return null;
  }
655566
private void nestedConstraint( PatternDescrBuilder< ? > pattern, String prefix ) throws RecognitionException {
        int prefixLenght = getNestedConstraintPrefixLenght();

        int prefixStart = input.index();
        prefix += input.toString( prefixStart, prefixStart + prefixLenght - 2 );
        for (int i = 0; i < prefixLenght; i++) {
            input.consume();
        }

        constraints( pattern, prefix );
        match( input,
                DRL5Lexer.RIGHT_PAREN,
                null,
                null,
                DroolsEditorType.SYMBOL );
    }
650579
public Expr or(Expr expr) {
        if (type == Type.TRUE ||
            type == Type.FALSE ||
            type == NONE) {
            set(expr);
        } else if (expr.type != Type.TRUE &&
                   expr.type != Type.FALSE &&
                   expr.type != Type.NONE) {
            if (type.isLogical() && !expr.type.isLogical()) {
                if (type == OR)
                    right.or(expr);
                else if (type != NOT)
                    setLogical(Type.OR, expr, new Expr(this));
                else
                    setLogical(Type.OR, new Expr(this), expr);
            }
            else
                setLogical(Type.OR, new Expr(this), expr);
        }
        return this;
    }
1238587
@Override
    protected Expression or(Expression base, Expression expression) {
        return Expr.or(base, expression);
    }
853776
@Override
	public boolean containsValidPrefix(final String key) {
		if (key != null) {
			lock.readLock().lock();
			try {
				for (final String aPrefix : prefixes) {
					if (key.equals(aPrefix) || key.startsWith(aPrefix + getPrefixDelimiter())) {
						return true;
					}
				}
			} finally {
				lock.readLock().unlock();
			}
		}
		return false;
	}
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;
  }
154797
String getSuffix(URI uri) {

        String fragment = uri.getFragment();
        if (fragment != null) {
            fragment = "#" + fragment;
        } else {
            fragment = "";
        }

        String query = uri.getRawQuery();
        if (query != null) {
            query = "?" + query;
        } else {
            query = "";
        }
        return query.concat(fragment);
    }
472138
def _mix_or_and_expr(self, or_expr, _and, check):
        

        or_expr, check1 = or_expr.pop_check()
        if isinstance(check1, checks.AndCheck):
            and_expr = check1
            and_expr.add_check(check)
        else:
            and_expr = checks.AndCheck(check1, check)
        return [('or_expr', or_expr.add_check(and_expr))]
919528
public static CharPredicate or(final CharPredicate... predicates) {
    if (predicates.length == 0)
      return NEVER;
    else if (predicates.length == 1) return predicates[0];
    return new CharPredicate() {
      @Override public boolean isChar(char c) {
        for(int i = 0;i < predicates.length;i++) {
          if (predicates[i].isChar(c)) return true;
        }
        return false;
      }
      @Override public String toString() {
        return Strings.join(" or ", predicates);
      }
    };
  }