1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:47:44 +00:00

Userland: Prefer _string over _short_string

As `_string` can't fail anymore (since 3434412), there are no real
benefits to use the short variant in most cases.
This commit is contained in:
Lucas CHOLLET 2023-08-07 22:26:17 -04:00 committed by Andreas Kling
parent a5edc9cdfc
commit 3f35ffb648
198 changed files with 684 additions and 684 deletions

View file

@ -1261,7 +1261,7 @@ ErrorOr<RefPtr<Value>> ForLoop::run(RefPtr<Shell> shell)
};
if (m_iterated_expression) {
auto variable_name = m_variable.has_value() ? m_variable->name : "it"_short_string;
auto variable_name = m_variable.has_value() ? m_variable->name : "it"_string;
Optional<StringView> index_name = m_index_variable.has_value() ? Optional<StringView>(m_index_variable->name) : Optional<StringView>();
size_t i = 0;
TRY(m_iterated_expression->for_each_entry(shell, [&](auto value) -> ErrorOr<IterationDecision> {
@ -3895,9 +3895,9 @@ ErrorOr<Vector<String>> SpecialVariableValue::resolve_as_list(RefPtr<Shell> shel
auto list_argv = static_cast<AST::ListValue const*>(argv.ptr());
return { resolve_slices(shell, Vector { TRY(String::number(list_argv->values().size())) }, m_slices) };
}
return { resolve_slices(shell, Vector { "1"_short_string }, m_slices) };
return { resolve_slices(shell, Vector { "1"_string }, m_slices) };
}
return { resolve_slices(shell, Vector { "0"_short_string }, m_slices) };
return { resolve_slices(shell, Vector { "0"_string }, m_slices) };
default:
return { resolve_slices(shell, Vector { String {} }, m_slices) };
}

View file

@ -1826,7 +1826,7 @@ ErrorOr<int> Shell::builtin_read(Main::Arguments arguments)
if (!parser.parse(arguments, Core::ArgsParser::FailureBehavior::Ignore))
return 1;
auto split_by_any_of = " \t\n"_short_string;
auto split_by_any_of = " \t\n"_string;
if (auto const* value_from_env = getenv("IFS"); value_from_env)
split_by_any_of = TRY(String::from_utf8({ value_from_env, strlen(value_from_env) }));

View file

@ -518,7 +518,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_null_or_alternative(AST::ImmediateEx
auto name = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_as_string(*this));
auto frame = find_frame_containing_local_variable(name);
if (!frame)
return make_ref_counted<AST::StringLiteral>(invoking_node.position(), ""_short_string, AST::StringLiteral::EnclosureType::None);
return make_ref_counted<AST::StringLiteral>(invoking_node.position(), ""_string, AST::StringLiteral::EnclosureType::None);
auto value = frame->local_variables.get(name.bytes_as_string_view()).value();
if ((value->is_string() && TRY(value->resolve_as_string(*this)).is_empty()) || (value->is_list() && TRY(value->resolve_as_list(*this)).is_empty()))

View file

@ -23,7 +23,7 @@
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
auto _error = _value_or_error.release_error();) \
if (_error.is_errno() && _error.code() == ENOMEM) \
return create<AST::SyntaxError>("OOM"_short_string); \
return create<AST::SyntaxError>("OOM"_string); \
return create<AST::SyntaxError>(MUST(String::formatted("Error: {}", _error))); \
} \
_value_or_error.release_value(); \
@ -38,7 +38,7 @@
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
auto _error = _value_or_error.release_error();) \
if (_error.is_errno() && _error.code() == ENOMEM) \
_string_value = "OOM"_short_string; \
_string_value = "OOM"_string; \
else \
_string_value = MUST(String::formatted("Error: {}", _error)); \
} \
@ -1762,7 +1762,7 @@ RefPtr<AST::Node> Parser::parse_history_designator()
consume();
selector.event.kind = AST::HistorySelector::EventKind::IndexFromEnd;
selector.event.index = 0;
selector.event.text = "!"_short_string;
selector.event.text = "!"_string;
break;
case '?':
consume();

View file

@ -728,7 +728,7 @@ ErrorOr<Lexer::ReductionResult> Lexer::reduce_arithmetic_expansion()
expansion.range.length = m_state.position.end_offset - expansion.range.start - m_state.position.start_offset;
return ReductionResult {
.tokens = { Token::continuation("$(("_short_string) },
.tokens = { Token::continuation("$(("_string) },
.next_reduction = m_state.previous_reduction,
};
}
@ -839,7 +839,7 @@ ErrorOr<Lexer::ReductionResult> Lexer::reduce_command_or_arithmetic_substitution
if (m_lexer.is_eof()) {
return ReductionResult {
.tokens = { Token::continuation("$("_short_string) },
.tokens = { Token::continuation("$("_string) },
.next_reduction = m_state.previous_reduction,
};
}
@ -883,7 +883,7 @@ ErrorOr<Lexer::ReductionResult> Lexer::reduce_extended_parameter_expansion()
if (m_lexer.is_eof()) {
return ReductionResult {
.tokens = { Token::continuation("${"_short_string) },
.tokens = { Token::continuation("${"_string) },
.next_reduction = m_state.previous_reduction,
};
}

View file

@ -357,7 +357,7 @@ struct Token {
{
return {
.type = Type::Newline,
.value = "\n"_short_string,
.value = "\n"_string,
.position = {},
.expansions = {},
.original_text = {},

View file

@ -17,7 +17,7 @@
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
auto _error = _value_or_error.release_error();) \
if (_error.is_errno() && _error.code() == ENOMEM) \
return make_ref_counted<AST::SyntaxError>(position, "OOM"_short_string); \
return make_ref_counted<AST::SyntaxError>(position, "OOM"_string); \
return make_ref_counted<AST::SyntaxError>(position, MUST(String::formatted("Error: {}", _error))); \
} \
_value_or_error.release_value(); \
@ -796,7 +796,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_pipe_sequence(bool is_negated)
Vector<NonnullRefPtr<AST::Node>> {
make_ref_counted<AST::BarewordLiteral>(
node->position(),
"not"_short_string),
"not"_string),
*static_cast<AST::CastToCommand&>(*node).inner() }));
}
}
@ -1388,7 +1388,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_for_clause()
name_position = peek().position;
name = consume().value;
} else {
name = "it"_short_string;
name = "it"_string;
error(peek(), "Expected a variable name, not {}", peek().type_name());
}
@ -1926,7 +1926,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_simple_command()
if (!definitions.is_empty()) {
nodes.append(make_ref_counted<AST::BarewordLiteral>(
empty_position(),
"--"_short_string));
"--"_string));
}
// WORD or io_redirect: IO_NUMBER or io_file

View file

@ -1743,7 +1743,7 @@ ErrorOr<Vector<Line::CompletionSuggestion>> Shell::complete_via_program_itself(s
else if (!options.invoke_program_for_autocomplete)
return Error::from_string_literal("Refusing to use the program itself as completion source");
completion_command.argv.extend({ "--complete"_string, "--"_short_string });
completion_command.argv.extend({ "--complete"_string, "--"_string });
struct Visitor : public AST::NodeVisitor {
Visitor(Shell& shell, AST::Position position)