Remove redundant string_view

depth-refraction
Evil Eye 2 years ago
parent 724c6ec425
commit c6a545766c

@ -471,46 +471,39 @@ namespace Compiler
size_t end = op.size(); size_t end = op.size();
while (end > 0 && (op[end - 1] == '\t' || op[end - 1] == ' ')) while (end > 0 && (op[end - 1] == '\t' || op[end - 1] == ' '))
--end; --end;
std::string_view trimmedOperator = std::string_view{ op }.substr(0, end); switch (op[0])
switch (trimmedOperator[0])
{ {
case '=': case '=':
special = S_cmpEQ; special = S_cmpEQ;
if (trimmedOperator.size() != 2 || trimmedOperator[1] != '=') if (end != 2 || op[1] != '=')
mErrorHandler.warning( mErrorHandler.warning("invalid operator " + op.substr(0, end) + ", treating it as ==", loc);
"invalid operator " + std::string(trimmedOperator) + ", treating it as ==", loc);
break; break;
case '<': case '<':
special = S_cmpLT; special = S_cmpLT;
if (trimmedOperator[1] == '=') if (op[1] == '=')
{ {
special = S_cmpLE; special = S_cmpLE;
if (trimmedOperator.size() != 2) if (end != 2)
mErrorHandler.warning( mErrorHandler.warning("invalid operator " + op.substr(0, end) + ", treating it as <=", loc);
"invalid operator " + std::string(trimmedOperator) + ", treating it as <=", loc);
} }
else if (trimmedOperator.size() != 1) else if (end != 1)
mErrorHandler.warning( mErrorHandler.warning("invalid operator " + op.substr(0, end) + ", treating it as <", loc);
"invalid operator " + std::string(trimmedOperator) + ", treating it as <", loc);
break; break;
case '>': case '>':
special = S_cmpGT; special = S_cmpGT;
if (trimmedOperator[1] == '=') if (op[1] == '=')
{ {
special = S_cmpGE; special = S_cmpGE;
if (trimmedOperator.size() != 2) if (end != 2)
mErrorHandler.warning( mErrorHandler.warning("invalid operator " + op.substr(0, end) + ", treating it as >=", loc);
"invalid operator " + std::string(trimmedOperator) + ", treating it as >=", loc);
} }
else if (trimmedOperator.size() != 1) else if (end != 1)
mErrorHandler.warning( mErrorHandler.warning("invalid operator " + op.substr(0, end) + ", treating it as >", loc);
"invalid operator " + std::string(trimmedOperator) + ", treating it as >", loc);
break; break;
case '!': case '!':
special = S_cmpNE; special = S_cmpNE;
if (trimmedOperator.size() != 2 || trimmedOperator[1] != '=') if (end != 2 || op[1] != '=')
mErrorHandler.warning( mErrorHandler.warning("invalid operator " + op.substr(0, end) + ", treating it as !=", loc);
"invalid operator " + std::string(trimmedOperator) + ", treating it as !=", loc);
break; break;
default: default:
return false; return false;

Loading…
Cancel
Save