1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 13:47:46 +00:00

AK: Rename Vector::append(Vector) => Vector::extend(Vector)

Let's make it a bit more clear when we're appending the elements from
one vector to the end of another vector.
This commit is contained in:
Andreas Kling 2021-06-12 13:24:45 +02:00
parent 7e1bffdeb8
commit dc65f54c06
37 changed files with 103 additions and 104 deletions

View file

@ -405,7 +405,7 @@ void EventLoop::pump(WaitMode mode)
new_event_queue.ensure_capacity(m_queued_events.size() + events.size());
for (++i; i < events.size(); ++i)
new_event_queue.unchecked_append(move(events[i]));
new_event_queue.append(move(m_queued_events));
new_event_queue.extend(move(m_queued_events));
m_queued_events = move(new_event_queue);
return;
}

View file

@ -58,7 +58,7 @@ public:
void take_pending_events_from(EventLoop& other)
{
m_queued_events.append(move(other.m_queued_events));
m_queued_events.extend(move(other.m_queued_events));
}
static void wake();

View file

@ -63,7 +63,7 @@ NonnullRefPtrVector<Declaration> FunctionDeclaration::declarations() const
}
if (m_definition)
declarations.append(m_definition->declarations());
declarations.extend(m_definition->declarations());
return declarations;
}
@ -131,7 +131,7 @@ NonnullRefPtrVector<Declaration> FunctionDefinition::declarations() const
{
NonnullRefPtrVector<Declaration> declarations;
for (auto& statement : m_statements) {
declarations.append(statement.declarations());
declarations.extend(statement.declarations());
}
return declarations;
}
@ -400,9 +400,9 @@ NonnullRefPtrVector<Declaration> ForStatement::declarations() const
{
NonnullRefPtrVector<Declaration> declarations;
if (m_init)
declarations.append(m_init->declarations());
declarations.extend(m_init->declarations());
if (m_body)
declarations.append(m_body->declarations());
declarations.extend(m_body->declarations());
return declarations;
}
@ -410,7 +410,7 @@ NonnullRefPtrVector<Declaration> BlockStatement::declarations() const
{
NonnullRefPtrVector<Declaration> declarations;
for (auto& statement : m_statements) {
declarations.append(statement.declarations());
declarations.extend(statement.declarations());
}
return declarations;
}
@ -439,11 +439,11 @@ NonnullRefPtrVector<Declaration> IfStatement::declarations() const
{
NonnullRefPtrVector<Declaration> declarations;
if (m_predicate)
declarations.append(m_predicate->declarations());
declarations.extend(m_predicate->declarations());
if (m_then)
declarations.append(m_then->declarations());
declarations.extend(m_then->declarations());
if (m_else)
declarations.append(m_else->declarations());
declarations.extend(m_else->declarations());
return declarations;
}

View file

@ -87,7 +87,7 @@ void DebugInfo::prepare_lines()
Vector<Dwarf::LineProgram::LineInfo> all_lines;
while (!stream.eof()) {
Dwarf::LineProgram program(m_dwarf_info, stream);
all_lines.append(program.lines());
all_lines.extend(program.lines());
}
HashMap<FlyString, Optional<String>> memoized_full_paths;

View file

@ -123,8 +123,8 @@ void FileSystemModel::Node::traverse_if_needed()
file_children.append(move(child));
}
children.append(move(directory_children));
children.append(move(file_children));
children.extend(move(directory_children));
children.extend(move(file_children));
if (!m_model.m_file_watcher->is_watching(full_path)) {
// We are not already watching this file, watch it

View file

@ -380,7 +380,7 @@ void Window::handle_multi_paint_event(MultiPaintEvent& event)
// It's possible that there had been some calls to update() that
// haven't been flushed. We can handle these right now, avoiding
// another round trip.
rects.append(move(m_pending_paint_event_rects));
rects.extend(move(m_pending_paint_event_rects));
}
VERIFY(!rects.is_empty());
if (m_back_store && m_back_store->size() != event.window_size()) {

View file

@ -424,9 +424,9 @@ static bool set_dib_bitmasks(BMPLoadingContext& context, InputStreamer& streamer
auto& type = context.dib_type;
if (type > DIBType::OSV2 && bpp == 16 && compression == Compression::RGB) {
context.dib.info.masks.append({ 0x7c00, 0x03e0, 0x001f });
context.dib.info.mask_shifts.append({ 7, 2, -3 });
context.dib.info.mask_sizes.append({ 5, 5, 5 });
context.dib.info.masks.extend({ 0x7c00, 0x03e0, 0x001f });
context.dib.info.mask_shifts.extend({ 7, 2, -3 });
context.dib.info.mask_sizes.extend({ 5, 5, 5 });
} else if (type == DIBType::Info && (compression == Compression::BITFIELDS || compression == Compression::ALPHABITFIELDS)) {
// Consume the extra BITFIELDS bytes
auto number_of_mask_fields = compression == Compression::ALPHABITFIELDS ? 4 : 3;

View file

@ -160,7 +160,7 @@ public:
void reset()
{
m_code_table.clear();
m_code_table.append(m_original_code_table);
m_code_table.extend(m_original_code_table);
m_code_size = m_original_code_size;
m_table_capacity = pow(2, m_code_size);
m_output.clear();

View file

@ -129,7 +129,7 @@ void PNGWriter::add_chunk(PNGChunk const& png_chunk)
for (auto character : png_chunk.type()) {
combined.append(character);
}
combined.append(png_chunk.data());
combined.extend(png_chunk.data());
auto crc = BigEndian(Crypto::Checksum::CRC32({ (const u8*)combined.data(), combined.size() }).digest());
auto data_len = BigEndian(png_chunk.data().size());

View file

@ -2230,12 +2230,12 @@ Value DebuggerStatement::execute(Interpreter& interpreter, GlobalObject&) const
void ScopeNode::add_variables(NonnullRefPtrVector<VariableDeclaration> variables)
{
m_variables.append(move(variables));
m_variables.extend(move(variables));
}
void ScopeNode::add_functions(NonnullRefPtrVector<FunctionDeclaration> functions)
{
m_functions.append(move(functions));
m_functions.extend(move(functions));
}
}

View file

@ -61,7 +61,7 @@ BoundFunction* Function::bind(Value bound_this_value, Vector<Value> arguments)
constructor_prototype = &prototype_property.as_object();
auto all_bound_arguments = bound_arguments();
all_bound_arguments.append(move(arguments));
all_bound_arguments.extend(move(arguments));
return heap().allocate<BoundFunction>(global_object(), global_object(), target_function, bound_this_object, move(all_bound_arguments), computed_length, constructor_prototype);
}

View file

@ -28,7 +28,7 @@ public:
MarkedValueList copy() const
{
MarkedValueList copy { m_heap };
copy.append(*this);
copy.extend(*this);
return copy;
}

View file

@ -373,7 +373,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
if (replace_value.is_function()) {
MarkedValueList replacer_args(vm.heap());
replacer_args.append(js_string(vm, matched));
replacer_args.append(move(captures));
replacer_args.extend(move(captures));
replacer_args.append(Value(position));
replacer_args.append(js_string(vm, string));
if (!named_captures.is_undefined()) {

View file

@ -397,7 +397,7 @@ Value VM::construct(Function& function, Function& new_target, Optional<MarkedVal
call_frame.function_name = function.name();
call_frame.arguments = function.bound_arguments();
if (arguments.has_value())
call_frame.arguments.append(arguments.value().values());
call_frame.arguments.extend(arguments.value().values());
auto* environment = function.create_environment();
call_frame.scope = environment;
if (environment)
@ -509,7 +509,7 @@ Value VM::call_internal(Function& function, Value this_value, Optional<MarkedVal
call_frame.this_value = function.bound_this().value_or(this_value);
call_frame.arguments = function.bound_arguments();
if (arguments.has_value())
call_frame.arguments.append(arguments.value().values());
call_frame.arguments.extend(arguments.value().values());
auto* environment = function.create_environment();
call_frame.scope = environment;

View file

@ -155,9 +155,9 @@ public:
}
bytecode.empend(arguments.size()); // size of arguments
bytecode.append(move(arguments));
bytecode.extend(move(arguments));
append(move(bytecode));
extend(move(bytecode));
}
void insert_bytecode_check_boundary(BoundaryCheckType type)
@ -166,7 +166,7 @@ public:
bytecode.empend((ByteCodeValueType)OpCodeId::CheckBoundary);
bytecode.empend((ByteCodeValueType)type);
append(move(bytecode));
extend(move(bytecode));
}
void insert_bytecode_compare_string(StringView view)
@ -182,9 +182,9 @@ public:
arguments.insert_string(view);
bytecode.empend(arguments.size()); // size of arguments
bytecode.append(move(arguments));
bytecode.extend(move(arguments));
append(move(bytecode));
extend(move(bytecode));
}
void insert_bytecode_compare_named_reference(StringView name)
@ -201,9 +201,9 @@ public:
arguments.empend(name.length());
bytecode.empend(arguments.size()); // size of arguments
bytecode.append(move(arguments));
bytecode.extend(move(arguments));
append(move(bytecode));
extend(move(bytecode));
}
void insert_bytecode_group_capture_left(size_t capture_groups_count)
@ -248,7 +248,7 @@ public:
// REGEXP BODY
// RESTORE
empend((ByteCodeValueType)OpCodeId::Save);
append(move(lookaround_body));
extend(move(lookaround_body));
empend((ByteCodeValueType)OpCodeId::Restore);
return;
}
@ -264,7 +264,7 @@ public:
auto body_length = lookaround_body.size();
empend((ByteCodeValueType)OpCodeId::Jump);
empend((ByteCodeValueType)body_length + 2); // JUMP to label _A
append(move(lookaround_body));
extend(move(lookaround_body));
empend((ByteCodeValueType)OpCodeId::FailForks);
empend((ByteCodeValueType)2); // Fail two forks
empend((ByteCodeValueType)OpCodeId::Save);
@ -281,7 +281,7 @@ public:
empend((ByteCodeValueType)OpCodeId::Save);
empend((ByteCodeValueType)OpCodeId::GoBack);
empend((ByteCodeValueType)match_length);
append(move(lookaround_body));
extend(move(lookaround_body));
empend((ByteCodeValueType)OpCodeId::Restore);
return;
case LookAroundType::NegatedLookBehind: {
@ -299,7 +299,7 @@ public:
empend((ByteCodeValueType)body_length + 4); // JUMP to label _A
empend((ByteCodeValueType)OpCodeId::GoBack);
empend((ByteCodeValueType)match_length);
append(move(lookaround_body));
extend(move(lookaround_body));
empend((ByteCodeValueType)OpCodeId::FailForks);
empend((ByteCodeValueType)2); // Fail two forks
empend((ByteCodeValueType)OpCodeId::Save);
@ -355,7 +355,7 @@ public:
new_bytecode.empend(diff * (bytecode_to_repeat.size() + 2)); // Jump to the _END label
for (size_t i = 0; i < diff; ++i) {
new_bytecode.append(bytecode_to_repeat);
new_bytecode.extend(bytecode_to_repeat);
new_bytecode.empend(jump_kind);
new_bytecode.empend((diff - i - 1) * (bytecode_to_repeat.size() + 2)); // Jump to the _END label
}
@ -373,7 +373,7 @@ public:
void insert_bytecode_repetition_n(ByteCode& bytecode_to_repeat, size_t n)
{
for (size_t i = 0; i < n; ++i)
append(bytecode_to_repeat);
extend(bytecode_to_repeat);
}
void insert_bytecode_repetition_min_one(ByteCode& bytecode_to_repeat, bool greedy)

View file

@ -473,7 +473,7 @@ ALWAYS_INLINE bool PosixExtendedParser::parse_sub_expression(ByteCode& stack, si
if (!parse_bracket_expression(sub_ops, length) || !sub_ops.size())
return set_error(Error::InvalidBracketContent);
bytecode.append(move(sub_ops));
bytecode.extend(move(sub_ops));
consume(TokenType::RightBracket, Error::MismatchingBracket);
should_parse_repetition_symbol = true;
@ -559,7 +559,7 @@ ALWAYS_INLINE bool PosixExtendedParser::parse_sub_expression(ByteCode& stack, si
if (!parse_root(capture_group_bytecode, length))
return set_error(Error::InvalidPattern);
bytecode.append(move(capture_group_bytecode));
bytecode.extend(move(capture_group_bytecode));
consume(TokenType::RightParen, Error::MismatchingParen);
@ -586,7 +586,7 @@ ALWAYS_INLINE bool PosixExtendedParser::parse_sub_expression(ByteCode& stack, si
return set_error(Error::InvalidRepetitionMarker);
}
stack.append(move(bytecode));
stack.extend(move(bytecode));
match_length_minimum += length;
return true;
@ -623,7 +623,7 @@ bool PosixExtendedParser::parse_root(ByteCode& stack, size_t& match_length_minim
if (bytecode_left.is_empty())
set_error(Error::EmptySubExpression);
stack.append(move(bytecode_left));
stack.extend(move(bytecode_left));
match_length_minimum = match_length_minimum_left;
return !has_error();
}
@ -648,7 +648,7 @@ bool ECMA262Parser::parse_internal(ByteCode& stack, size_t& match_length_minimum
if (!res)
return false;
stack.append(new_stack);
stack.extend(new_stack);
match_length_minimum = new_match_length;
return res;
}
@ -668,7 +668,7 @@ bool ECMA262Parser::parse_disjunction(ByteCode& stack, size_t& match_length_mini
return false;
if (!match(TokenType::Pipe)) {
stack.append(left_alternative_stack);
stack.extend(left_alternative_stack);
match_length_minimum = left_alternative_min_length;
return alt_ok;
}
@ -726,7 +726,7 @@ bool ECMA262Parser::parse_term(ByteCode& stack, size_t& match_length_minimum, bo
if (!parse_with_quantifier())
return false;
stack.append(move(atom_stack));
stack.extend(move(atom_stack));
match_length_minimum += minimum_atom_length;
return true;
}
@ -783,7 +783,7 @@ bool ECMA262Parser::parse_assertion(ByteCode& stack, [[maybe_unused]] size_t& ma
if (m_should_use_browser_extended_grammar) {
if (!unicode) {
if (parse_quantifiable_assertion(assertion_stack, match_length_minimum, named)) {
stack.append(move(assertion_stack));
stack.extend(move(assertion_stack));
return true;
}
}
@ -1656,7 +1656,7 @@ bool ECMA262Parser::parse_capture_group(ByteCode& stack, size_t& match_length_mi
consume(TokenType::RightParen, Error::MismatchingParen);
stack.append(move(noncapture_group_bytecode));
stack.extend(move(noncapture_group_bytecode));
match_length_minimum += length;
return true;
}
@ -1680,7 +1680,7 @@ bool ECMA262Parser::parse_capture_group(ByteCode& stack, size_t& match_length_mi
stack.insert_bytecode_group_capture_left(name);
stack.insert_bytecode_group_capture_left(group_index);
stack.append(move(capture_group_bytecode));
stack.extend(move(capture_group_bytecode));
stack.insert_bytecode_group_capture_right(name);
stack.insert_bytecode_group_capture_right(group_index);
@ -1704,7 +1704,7 @@ bool ECMA262Parser::parse_capture_group(ByteCode& stack, size_t& match_length_mi
if (!parse_disjunction(capture_group_bytecode, length, unicode, named))
return set_error(Error::InvalidPattern);
stack.append(move(capture_group_bytecode));
stack.extend(move(capture_group_bytecode));
m_parser_state.capture_group_minimum_lengths.set(group_index, length);

View file

@ -111,7 +111,7 @@ static ParseResult<ParseUntilAnyOfResult<T>> parse_until_any_of(InputStream& str
if (parse_result.is_error())
return parse_result.error();
result.values.append(parse_result.release_value());
result.values.extend(parse_result.release_value());
}
}
@ -312,7 +312,7 @@ ParseResult<Vector<Instruction>> Instruction::parse(InputStream& stream, Instruc
// Transform op(..., instr*, instr*) -> op(...) instr* op(else(ip) instr* op(end(ip))
VERIFY(result.value().terminator == 0x05);
instructions.append(result.release_value().values);
instructions.extend(result.release_value().values);
instructions.append(Instruction { Instructions::structured_else });
++ip;
else_ip = ip.value();
@ -322,7 +322,7 @@ ParseResult<Vector<Instruction>> Instruction::parse(InputStream& stream, Instruc
auto result = parse_until_any_of<Instruction, 0x0b>(stream, ip);
if (result.is_error())
return result.error();
instructions.append(result.release_value().values);
instructions.extend(result.release_value().values);
instructions.append(Instruction { Instructions::structured_end });
++ip;
end_ip = ip.value();

View file

@ -1560,8 +1560,7 @@ _StartOfFunction:
log_parse_error();
}
m_temporary_buffer.clear();
m_temporary_buffer.append(match.value().code_points);
m_temporary_buffer = match.value().code_points;
FLUSH_CODEPOINTS_CONSUMED_AS_A_CHARACTER_REFERENCE;
SWITCH_TO_RETURN_STATE;

View file

@ -99,7 +99,7 @@ void SyntaxHighlighter::rehighlight(Palette const& palette)
register_nested_token_pairs(proxy_client.corrected_token_pairs(highlighter.matching_token_pairs()));
}
spans.append(proxy_client.corrected_spans());
spans.extend(proxy_client.corrected_spans());
substring_builder.clear();
} else if (state == State::CSS) {
// FIXME: Highlight CSS code here instead.

View file

@ -279,23 +279,23 @@ Vector<Vector<float>> PathDataParser::parse_coordinate_pair_sequence()
Vector<float> PathDataParser::parse_coordinate_pair_double()
{
Vector<float> coordinates;
coordinates.append(parse_coordinate_pair());
coordinates.extend(parse_coordinate_pair());
if (match_comma_whitespace())
parse_comma_whitespace();
coordinates.append(parse_coordinate_pair());
coordinates.extend(parse_coordinate_pair());
return coordinates;
}
Vector<float> PathDataParser::parse_coordinate_pair_triplet()
{
Vector<float> coordinates;
coordinates.append(parse_coordinate_pair());
coordinates.extend(parse_coordinate_pair());
if (match_comma_whitespace())
parse_comma_whitespace();
coordinates.append(parse_coordinate_pair());
coordinates.extend(parse_coordinate_pair());
if (match_comma_whitespace())
parse_comma_whitespace();
coordinates.append(parse_coordinate_pair());
coordinates.extend(parse_coordinate_pair());
return coordinates;
}
@ -316,7 +316,7 @@ Vector<float> PathDataParser::parse_elliptical_arg_argument()
numbers.append(parse_flag());
if (match_comma_whitespace())
parse_comma_whitespace();
numbers.append(parse_coordinate_pair());
numbers.extend(parse_coordinate_pair());
return numbers;
}