mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 06:49:28 -05:00
refactor: use std ranges functions where applicable
This commit is contained in:
@ -981,7 +981,7 @@ void DefinesStreamProxy::ProcessNestedMacros(ParserLine& line, unsigned& linePos
|
||||
const Define* nestedMacro = nullptr;
|
||||
while (FindNextMacro(input, pos, defineStart, nestedMacro))
|
||||
{
|
||||
if (std::find(callstack.cbegin(), callstack.cend(), nestedMacro) != callstack.cend())
|
||||
if (std::ranges::find(std::as_const(callstack), nestedMacro) != callstack.cend())
|
||||
{
|
||||
// Do not expand recursively
|
||||
continue;
|
||||
|
@ -283,18 +283,16 @@ std::unique_ptr<SimpleExpressionMatchers::matcher_t> SimpleExpressionMatchers::P
|
||||
}
|
||||
}
|
||||
|
||||
const auto hasAddOperation = std::any_of(enabledBinaryOperations.begin(),
|
||||
enabledBinaryOperations.end(),
|
||||
[](const SimpleExpressionBinaryOperationType* type)
|
||||
{
|
||||
return type == &SimpleExpressionBinaryOperationType::OPERATION_ADD;
|
||||
});
|
||||
const auto hasSubtractOperation = std::any_of(enabledBinaryOperations.begin(),
|
||||
enabledBinaryOperations.end(),
|
||||
[](const SimpleExpressionBinaryOperationType* type)
|
||||
{
|
||||
return type == &SimpleExpressionBinaryOperationType::OPERATION_SUBTRACT;
|
||||
});
|
||||
const auto hasAddOperation = std::ranges::any_of(enabledBinaryOperations,
|
||||
[](const SimpleExpressionBinaryOperationType* type)
|
||||
{
|
||||
return type == &SimpleExpressionBinaryOperationType::OPERATION_ADD;
|
||||
});
|
||||
const auto hasSubtractOperation = std::ranges::any_of(enabledBinaryOperations,
|
||||
[](const SimpleExpressionBinaryOperationType* type)
|
||||
{
|
||||
return type == &SimpleExpressionBinaryOperationType::OPERATION_SUBTRACT;
|
||||
});
|
||||
|
||||
if (hasAddOperation && hasSubtractOperation)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ SimpleMatcherAnyCharacterBesides::SimpleMatcherAnyCharacterBesides(std::vector<c
|
||||
MatcherResult<SimpleParserValue> SimpleMatcherAnyCharacterBesides::CanMatch(ILexer<SimpleParserValue>* lexer, const unsigned tokenOffset)
|
||||
{
|
||||
const auto& token = lexer->GetToken(tokenOffset);
|
||||
return token.m_type == SimpleParserValueType::CHARACTER && std::find(m_chars.begin(), m_chars.end(), token.CharacterValue()) == m_chars.end()
|
||||
return token.m_type == SimpleParserValueType::CHARACTER && std::ranges::find(m_chars, token.CharacterValue()) == m_chars.end()
|
||||
? MatcherResult<SimpleParserValue>::Match(1)
|
||||
: MatcherResult<SimpleParserValue>::NoMatch();
|
||||
}
|
||||
|
@ -17,14 +17,12 @@ MatcherResult<SimpleParserValue> SimpleMatcherKeywordIgnoreCase::CanMatch(ILexer
|
||||
return MatcherResult<SimpleParserValue>::NoMatch();
|
||||
|
||||
const auto& identifierValue = token.IdentifierValue();
|
||||
const auto isEqual = std::equal(identifierValue.begin(),
|
||||
identifierValue.end(),
|
||||
m_value.begin(),
|
||||
m_value.end(),
|
||||
[](const char a, const char b)
|
||||
{
|
||||
return tolower(a) == b;
|
||||
});
|
||||
const auto isEqual = std::ranges::equal(identifierValue,
|
||||
m_value,
|
||||
[](const char a, const char b)
|
||||
{
|
||||
return tolower(a) == b;
|
||||
});
|
||||
|
||||
if (isEqual)
|
||||
return MatcherResult<SimpleParserValue>::Match(1);
|
||||
|
Reference in New Issue
Block a user