summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSQL/AST
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2022-07-11 17:32:29 +0000
committerAndreas Kling <kling@serenityos.org>2022-07-12 23:11:35 +0200
commit3f3f45580ab7266258e97cb3cecf1e24716d61c5 (patch)
tree152c7a187c98184d58bf91a326357e0af435edcf /Userland/Libraries/LibSQL/AST
parente5f09ea1703bacfbb79a4ad3c587a7d5d3d7bb13 (diff)
downloadserenity-3f3f45580ab7266258e97cb3cecf1e24716d61c5.zip
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
Diffstat (limited to 'Userland/Libraries/LibSQL/AST')
-rw-r--r--Userland/Libraries/LibSQL/AST/Expression.cpp6
-rw-r--r--Userland/Libraries/LibSQL/AST/Lexer.cpp8
-rw-r--r--Userland/Libraries/LibSQL/AST/Parser.cpp22
-rw-r--r--Userland/Libraries/LibSQL/AST/Token.cpp2
4 files changed, 19 insertions, 19 deletions
diff --git a/Userland/Libraries/LibSQL/AST/Expression.cpp b/Userland/Libraries/LibSQL/AST/Expression.cpp
index b8706915f4..839b2cf235 100644
--- a/Userland/Libraries/LibSQL/AST/Expression.cpp
+++ b/Userland/Libraries/LibSQL/AST/Expression.cpp
@@ -12,7 +12,7 @@
namespace SQL::AST {
-static constexpr StringView s_posix_basic_metacharacters = ".^$*[]+\\";
+static constexpr auto s_posix_basic_metacharacters = ".^$*[]+\\"sv;
ResultOr<Value> NumericLiteral::evaluate(ExecutionContext&) const
{
@@ -205,7 +205,7 @@ ResultOr<Value> MatchExpression::evaluate(ExecutionContext& context) const
} else if (c == '_' && !escaped) {
builder.append('.');
} else if (c == '%' && !escaped) {
- builder.append(".*");
+ builder.append(".*"sv);
} else {
escaped = false;
builder.append(c);
@@ -226,7 +226,7 @@ ResultOr<Value> MatchExpression::evaluate(ExecutionContext& context) const
auto err = regex.parser_result.error;
if (err != regex::Error::NoError) {
StringBuilder builder;
- builder.append("Regular expression: ");
+ builder.append("Regular expression: "sv);
builder.append(get_error_string(err));
return Result { SQLCommand::Unknown, SQLErrorCode::SyntaxError, builder.build() };
diff --git a/Userland/Libraries/LibSQL/AST/Lexer.cpp b/Userland/Libraries/LibSQL/AST/Lexer.cpp
index 7a78028cb6..304d991c0e 100644
--- a/Userland/Libraries/LibSQL/AST/Lexer.cpp
+++ b/Userland/Libraries/LibSQL/AST/Lexer.cpp
@@ -27,16 +27,16 @@ Lexer::Lexer(StringView source)
}
if (s_one_char_tokens.is_empty()) {
-#define __ENUMERATE_SQL_TOKEN(value, type, category) \
- if (TokenCategory::category != TokenCategory::Keyword && StringView(value).length() == 1) \
+#define __ENUMERATE_SQL_TOKEN(value, type, category) \
+ if (TokenCategory::category != TokenCategory::Keyword && value##sv.length() == 1) \
s_one_char_tokens.set(value[0], TokenType::type);
ENUMERATE_SQL_TOKENS
#undef __ENUMERATE_SQL_TOKEN
}
if (s_two_char_tokens.is_empty()) {
-#define __ENUMERATE_SQL_TOKEN(value, type, category) \
- if (TokenCategory::category != TokenCategory::Keyword && StringView(value).length() == 2) \
+#define __ENUMERATE_SQL_TOKEN(value, type, category) \
+ if (TokenCategory::category != TokenCategory::Keyword && value##sv.length() == 2) \
s_two_char_tokens.set(value, TokenType::type);
ENUMERATE_SQL_TOKENS
#undef __ENUMERATE_SQL_TOKEN
diff --git a/Userland/Libraries/LibSQL/AST/Parser.cpp b/Userland/Libraries/LibSQL/AST/Parser.cpp
index 94ed6f55e3..3f18b34fe4 100644
--- a/Userland/Libraries/LibSQL/AST/Parser.cpp
+++ b/Userland/Libraries/LibSQL/AST/Parser.cpp
@@ -58,7 +58,7 @@ NonnullRefPtr<Statement> Parser::parse_statement()
case TokenType::Select:
return parse_select_statement({});
default:
- expected("CREATE, ALTER, DROP, DESCRIBE, INSERT, UPDATE, DELETE, or SELECT");
+ expected("CREATE, ALTER, DROP, DESCRIBE, INSERT, UPDATE, DELETE, or SELECT"sv);
return create_ast_node<ErrorStatement>();
}
}
@@ -75,7 +75,7 @@ NonnullRefPtr<Statement> Parser::parse_statement_with_expression_list(RefPtr<Com
case TokenType::Select:
return parse_select_statement(move(common_table_expression_list));
default:
- expected("INSERT, UPDATE, DELETE, or SELECT");
+ expected("INSERT, UPDATE, DELETE, or SELECT"sv);
return create_ast_node<ErrorStatement>();
}
}
@@ -226,7 +226,7 @@ NonnullRefPtr<Insert> Parser::parse_insert_statement(RefPtr<CommonTableExpressio
chained_expressions.append(static_ptr_cast<ChainedExpression>(chained_expression.release_nonnull()));
}
} else {
- expected("Chained expression");
+ expected("Chained expression"sv);
}
});
} else if (match(TokenType::Select)) {
@@ -381,7 +381,7 @@ RefPtr<CommonTableExpressionList> Parser::parse_common_table_expression_list()
parse_comma_separated_list(false, [&]() { common_table_expression.append(parse_common_table_expression()); });
if (common_table_expression.is_empty()) {
- expected("Common table expression list");
+ expected("Common table expression list"sv);
return {};
}
@@ -432,7 +432,7 @@ NonnullRefPtr<Expression> Parser::parse_primary_expression()
if (auto expression = parse_exists_expression(false))
return expression.release_nonnull();
- expected("Primary Expression");
+ expected("Primary Expression"sv);
consume();
return create_ast_node<ErrorExpression>();
@@ -465,7 +465,7 @@ NonnullRefPtr<Expression> Parser::parse_secondary_expression(NonnullRefPtr<Expre
if (auto expression = parse_in_expression(primary, invert_expression))
return expression.release_nonnull();
- expected("Secondary Expression");
+ expected("Secondary Expression"sv);
consume();
return create_ast_node<ErrorExpression>();
@@ -805,13 +805,13 @@ RefPtr<Expression> Parser::parse_between_expression(NonnullRefPtr<Expression> ex
auto nested = parse_expression();
if (!is<BinaryOperatorExpression>(*nested)) {
- expected("Binary Expression");
+ expected("Binary Expression"sv);
return create_ast_node<ErrorExpression>();
}
auto const& binary_expression = static_cast<BinaryOperatorExpression const&>(*nested);
if (binary_expression.type() != BinaryOperator::And) {
- expected("AND Expression");
+ expected("AND Expression"sv);
return create_ast_node<ErrorExpression>();
}
@@ -903,7 +903,7 @@ NonnullRefPtr<SignedNumber> Parser::parse_signed_number()
return create_ast_node<SignedNumber>(is_positive ? number : (number * -1));
}
- expected("NumericLiteral");
+ expected("NumericLiteral"sv);
return create_ast_node<SignedNumber>(0);
}
@@ -1047,7 +1047,7 @@ NonnullRefPtr<OrderingTerm> Parser::parse_ordering_term()
else if (consume_if(TokenType::Last))
nulls = Nulls::Last;
else
- expected("FIRST or LAST");
+ expected("FIRST or LAST"sv);
}
return create_ast_node<OrderingTerm>(move(expression), move(collation_name), order, nulls);
@@ -1080,7 +1080,7 @@ ConflictResolution Parser::parse_conflict_resolution()
if (consume_if(TokenType::Rollback))
return ConflictResolution::Rollback;
- expected("ABORT, FAIL, IGNORE, REPLACE, or ROLLBACK");
+ expected("ABORT, FAIL, IGNORE, REPLACE, or ROLLBACK"sv);
}
return ConflictResolution::Abort;
diff --git a/Userland/Libraries/LibSQL/AST/Token.cpp b/Userland/Libraries/LibSQL/AST/Token.cpp
index 9acd3370de..0e33bd5dd0 100644
--- a/Userland/Libraries/LibSQL/AST/Token.cpp
+++ b/Userland/Libraries/LibSQL/AST/Token.cpp
@@ -16,7 +16,7 @@ StringView Token::name(TokenType type)
switch (type) {
#define __ENUMERATE_SQL_TOKEN(value, type, category) \
case TokenType::type: \
- return #type;
+ return #type##sv;
ENUMERATE_SQL_TOKENS
#undef __ENUMERATE_SQL_TOKEN
default: