1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:37:45 +00:00

Everywhere: Stop using NonnullOwnPtrVector

Same as NonnullRefPtrVector: weird semantics, questionable benefits.
This commit is contained in:
Andreas Kling 2023-03-06 17:16:25 +01:00
parent 689ca370d4
commit 359d6e7b0b
111 changed files with 517 additions and 503 deletions

View file

@ -75,13 +75,13 @@ GUI::ModelIndex ClassViewModel::parent_index(const GUI::ModelIndex& index) const
if (parent->parent == nullptr) {
for (size_t row = 0; row < m_root_scope.size(); row++) {
if (m_root_scope.ptr_at(row).ptr() == parent)
if (m_root_scope[row].ptr() == parent)
return create_index(row, 0, parent);
}
VERIFY_NOT_REACHED();
}
for (size_t row = 0; row < parent->parent->children.size(); row++) {
ClassViewNode* child_at_row = parent->parent->children.ptr_at(row).ptr();
ClassViewNode* child_at_row = parent->parent->children[row].ptr();
if (child_at_row == parent)
return create_index(row, 0, parent);
}
@ -110,7 +110,7 @@ ClassViewModel::ClassViewModel()
});
}
static ClassViewNode& add_child_node(NonnullOwnPtrVector<ClassViewNode>& children, NonnullOwnPtr<ClassViewNode>&& node_ptr, ClassViewNode* parent, CodeComprehension::Declaration const* declaration)
static ClassViewNode& add_child_node(Vector<NonnullOwnPtr<ClassViewNode>>& children, NonnullOwnPtr<ClassViewNode>&& node_ptr, ClassViewNode* parent, CodeComprehension::Declaration const* declaration)
{
node_ptr->parent = parent;
node_ptr->declaration = declaration;
@ -124,7 +124,7 @@ static ClassViewNode& add_child_node(NonnullOwnPtrVector<ClassViewNode>& childre
},
0, &inserted_index);
return children.at(inserted_index);
return *children.at(inserted_index);
}
void ClassViewModel::add_declaration(CodeComprehension::Declaration const& decl)
@ -135,21 +135,21 @@ void ClassViewModel::add_declaration(CodeComprehension::Declaration const& decl)
if (!scope_parts.is_empty()) {
// Traverse declarations tree to the parent of 'decl'
for (auto& node : m_root_scope) {
if (node.name == scope_parts.first())
parent = &node;
if (node->name == scope_parts.first())
parent = node;
}
if (parent == nullptr) {
m_root_scope.append(make<ClassViewNode>(scope_parts.first()));
parent = &m_root_scope.last();
parent = m_root_scope.last();
}
for (size_t i = 1; i < scope_parts.size(); ++i) {
auto& scope = scope_parts[i];
ClassViewNode* next { nullptr };
for (auto& child : parent->children) {
if (child.name == scope) {
next = &child;
if (child->name == scope) {
next = child;
break;
}
}
@ -163,7 +163,7 @@ void ClassViewModel::add_declaration(CodeComprehension::Declaration const& decl)
}
}
NonnullOwnPtrVector<ClassViewNode>* children_of_parent = nullptr;
Vector<NonnullOwnPtr<ClassViewNode>>* children_of_parent = nullptr;
if (parent) {
children_of_parent = &parent->children;
} else {
@ -172,10 +172,10 @@ void ClassViewModel::add_declaration(CodeComprehension::Declaration const& decl)
bool already_exists = false;
for (auto& child : *children_of_parent) {
if (child.name == decl.name) {
if (child->name == decl.name) {
already_exists = true;
if (!child.declaration) {
child.declaration = &decl;
if (!child->declaration) {
child->declaration = &decl;
}
break;
}

View file

@ -32,7 +32,7 @@ private:
struct ClassViewNode {
StringView name;
CodeComprehension::Declaration const* declaration { nullptr };
NonnullOwnPtrVector<ClassViewNode> children;
Vector<NonnullOwnPtr<ClassViewNode>> children;
ClassViewNode* parent { nullptr };
explicit ClassViewNode(StringView name)
@ -51,7 +51,7 @@ public:
private:
explicit ClassViewModel();
void add_declaration(CodeComprehension::Declaration const&);
NonnullOwnPtrVector<ClassViewNode> m_root_scope;
Vector<NonnullOwnPtr<ClassViewNode>> m_root_scope;
};
}

View file

@ -35,12 +35,12 @@ GUI::ModelIndex VariablesModel::parent_index(const GUI::ModelIndex& index) const
if (parent->parent == nullptr) {
for (size_t row = 0; row < m_variables.size(); row++)
if (m_variables.ptr_at(row).ptr() == parent)
if (m_variables[row].ptr() == parent)
return create_index(row, 0, parent);
VERIFY_NOT_REACHED();
}
for (size_t row = 0; row < parent->parent->members.size(); row++) {
Debug::DebugInfo::VariableInfo* child_at_row = parent->parent->members.ptr_at(row).ptr();
Debug::DebugInfo::VariableInfo* child_at_row = parent->parent->members[row].ptr();
if (child_at_row == parent)
return create_index(row, 0, parent);
}

View file

@ -28,14 +28,14 @@ public:
Debug::ProcessInspector& inspector() { return m_inspector; }
private:
explicit VariablesModel(Debug::ProcessInspector& inspector, NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo>&& variables, PtraceRegisters const& regs)
explicit VariablesModel(Debug::ProcessInspector& inspector, Vector<NonnullOwnPtr<Debug::DebugInfo::VariableInfo>>&& variables, PtraceRegisters const& regs)
: m_variables(move(variables))
, m_regs(regs)
, m_inspector(inspector)
{
m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors());
}
NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo> m_variables;
Vector<NonnullOwnPtr<Debug::DebugInfo::VariableInfo>> m_variables;
PtraceRegisters m_regs;
GUI::Icon m_variable_icon;