mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:47:45 +00:00
Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
This commit is contained in:
parent
689ca370d4
commit
359d6e7b0b
111 changed files with 517 additions and 503 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
RemoteObjectPropertyModel& property_model();
|
||||
|
||||
RemoteObject* parent { nullptr };
|
||||
NonnullOwnPtrVector<RemoteObject> children;
|
||||
Vector<NonnullOwnPtr<RemoteObject>> children;
|
||||
|
||||
FlatPtr address { 0 };
|
||||
FlatPtr parent_address { 0 };
|
||||
|
|
|
@ -45,7 +45,7 @@ GUI::ModelIndex RemoteObjectGraphModel::parent_index(const GUI::ModelIndex& inde
|
|||
// NOTE: If the parent has no parent, it's a root, so we have to look among the remote roots.
|
||||
if (!remote_object.parent->parent) {
|
||||
for (size_t row = 0; row < m_process.roots().size(); ++row) {
|
||||
if (&m_process.roots()[row] == remote_object.parent)
|
||||
if (m_process.roots()[row] == remote_object.parent)
|
||||
return create_index(row, 0, remote_object.parent);
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -53,7 +53,7 @@ GUI::ModelIndex RemoteObjectGraphModel::parent_index(const GUI::ModelIndex& inde
|
|||
}
|
||||
|
||||
for (size_t row = 0; row < remote_object.parent->parent->children.size(); ++row) {
|
||||
if (&remote_object.parent->parent->children[row] == remote_object.parent)
|
||||
if (remote_object.parent->parent->children[row] == remote_object.parent)
|
||||
return create_index(row, 0, remote_object.parent);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ GUI::ModelIndex RemoteObjectPropertyModel::index(int row, int column, const GUI:
|
|||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
return &m_paths.last();
|
||||
return m_paths.last();
|
||||
};
|
||||
|
||||
if (!parent.is_valid()) {
|
||||
|
@ -176,16 +176,16 @@ JsonPath const* RemoteObjectPropertyModel::cached_path_at(int n, Vector<JsonPath
|
|||
JsonPath const* index_path = nullptr;
|
||||
int row_index = n;
|
||||
for (auto& path : m_paths) {
|
||||
if (path.size() != prefix.size() + 1)
|
||||
if (path->size() != prefix.size() + 1)
|
||||
continue;
|
||||
|
||||
for (size_t i = 0; i < prefix.size(); ++i) {
|
||||
if (path[i] != prefix[i])
|
||||
if ((*path)[i] != prefix[i])
|
||||
goto do_continue;
|
||||
}
|
||||
|
||||
if (row_index == 0) {
|
||||
index_path = &path;
|
||||
index_path = path;
|
||||
break;
|
||||
}
|
||||
--row_index;
|
||||
|
@ -198,15 +198,15 @@ JsonPath const* RemoteObjectPropertyModel::cached_path_at(int n, Vector<JsonPath
|
|||
JsonPath const* RemoteObjectPropertyModel::find_cached_path(Vector<JsonPathElement> const& path) const
|
||||
{
|
||||
for (auto& cpath : m_paths) {
|
||||
if (cpath.size() != path.size())
|
||||
if (cpath->size() != path.size())
|
||||
continue;
|
||||
|
||||
for (size_t i = 0; i < cpath.size(); ++i) {
|
||||
if (cpath[i] != path[i])
|
||||
for (size_t i = 0; i < cpath->size(); ++i) {
|
||||
if ((*cpath)[i] != path[i])
|
||||
goto do_continue;
|
||||
}
|
||||
|
||||
return &cpath;
|
||||
return cpath;
|
||||
do_continue:;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ private:
|
|||
JsonPath const* find_cached_path(Vector<JsonPathElement> const& path) const;
|
||||
|
||||
RemoteObject& m_object;
|
||||
mutable NonnullOwnPtrVector<JsonPath> m_paths;
|
||||
mutable Vector<NonnullOwnPtr<JsonPath>> m_paths;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ void RemoteProcess::handle_get_all_objects_response(JsonObject const& response)
|
|||
// FIXME: It would be good if we didn't have to make a local copy of the array value here!
|
||||
auto& object_array = response.get_array("objects"sv).value();
|
||||
|
||||
NonnullOwnPtrVector<RemoteObject> remote_objects;
|
||||
Vector<NonnullOwnPtr<RemoteObject>> remote_objects;
|
||||
HashMap<FlatPtr, RemoteObject*> objects_by_address;
|
||||
|
||||
for (auto& value : object_array.values()) {
|
||||
|
@ -59,7 +59,7 @@ void RemoteProcess::handle_get_all_objects_response(JsonObject const& response)
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < remote_objects.size(); ++i) {
|
||||
auto& remote_object = remote_objects.ptr_at(i);
|
||||
auto& remote_object = remote_objects[i];
|
||||
auto* parent = objects_by_address.get(remote_object->parent_address).value_or(nullptr);
|
||||
if (!parent) {
|
||||
m_roots.append(move(remote_object));
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
DeprecatedString const& process_name() const { return m_process_name; }
|
||||
|
||||
RemoteObjectGraphModel& object_graph_model() { return *m_object_graph_model; }
|
||||
NonnullOwnPtrVector<RemoteObject> const& roots() const { return m_roots; }
|
||||
Vector<NonnullOwnPtr<RemoteObject>> const& roots() const { return m_roots; }
|
||||
|
||||
void set_inspected_object(FlatPtr);
|
||||
|
||||
|
@ -42,7 +42,7 @@ private:
|
|||
pid_t m_pid { -1 };
|
||||
DeprecatedString m_process_name;
|
||||
NonnullRefPtr<RemoteObjectGraphModel> m_object_graph_model;
|
||||
NonnullOwnPtrVector<RemoteObject> m_roots;
|
||||
Vector<NonnullOwnPtr<RemoteObject>> m_roots;
|
||||
RefPtr<InspectorServerClient> m_client;
|
||||
};
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
return Error::from_string_literal("Malformed profile (events is not an array)");
|
||||
auto const& perf_events = events_value.value();
|
||||
|
||||
NonnullOwnPtrVector<Process> all_processes;
|
||||
Vector<NonnullOwnPtr<Process>> all_processes;
|
||||
HashMap<pid_t, Process*> current_processes;
|
||||
Vector<Event> events;
|
||||
EventSerialNumber next_serial;
|
||||
|
@ -448,15 +448,15 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
return Error::from_string_literal("No events captured (targeted process was never on CPU)");
|
||||
|
||||
quick_sort(all_processes, [](auto& a, auto& b) {
|
||||
if (a.pid == b.pid)
|
||||
return a.start_valid < b.start_valid;
|
||||
if (a->pid == b->pid)
|
||||
return a->start_valid < b->start_valid;
|
||||
|
||||
return a.pid < b.pid;
|
||||
return a->pid < b->pid;
|
||||
});
|
||||
|
||||
Vector<Process> processes;
|
||||
for (auto& it : all_processes)
|
||||
processes.append(move(it));
|
||||
processes.append(move(*it));
|
||||
|
||||
return adopt_nonnull_own_or_enomem(new (nothrow) Profile(move(processes), move(events)));
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
Emulator(DeprecatedString const& executable_path, Vector<StringView> const& arguments, Vector<DeprecatedString> const& environment);
|
||||
|
||||
void set_profiling_details(bool should_dump_profile, size_t instruction_interval, Stream* profile_stream, NonnullOwnPtrVector<DeprecatedString>* profiler_strings, Vector<int>* profiler_string_id_map)
|
||||
void set_profiling_details(bool should_dump_profile, size_t instruction_interval, Stream* profile_stream, Vector<NonnullOwnPtr<DeprecatedString>>* profiler_strings, Vector<int>* profiler_string_id_map)
|
||||
{
|
||||
m_is_profiling = should_dump_profile;
|
||||
m_profile_instruction_interval = instruction_interval;
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
}
|
||||
|
||||
Stream& profile_stream() { return *m_profile_stream; }
|
||||
NonnullOwnPtrVector<DeprecatedString>& profiler_strings() { return *m_profiler_strings; }
|
||||
Vector<NonnullOwnPtr<DeprecatedString>>& profiler_strings() { return *m_profiler_strings; }
|
||||
Vector<int>& profiler_string_id_map() { return *m_profiler_string_id_map; }
|
||||
|
||||
bool is_profiling() const { return m_is_profiling; }
|
||||
|
@ -296,7 +296,7 @@ private:
|
|||
|
||||
Stream* m_profile_stream { nullptr };
|
||||
Vector<int>* m_profiler_string_id_map { nullptr };
|
||||
NonnullOwnPtrVector<DeprecatedString>* m_profiler_strings { nullptr };
|
||||
Vector<NonnullOwnPtr<DeprecatedString>>* m_profiler_strings { nullptr };
|
||||
|
||||
bool m_is_profiling { false };
|
||||
size_t m_profile_instruction_interval { 0 };
|
||||
|
|
|
@ -144,7 +144,7 @@ private:
|
|||
Region* m_page_to_region_map[786432] = { nullptr };
|
||||
|
||||
OwnPtr<Region> m_tls_region;
|
||||
NonnullOwnPtrVector<Region> m_regions;
|
||||
Vector<NonnullOwnPtr<Region>> m_regions;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ int main(int argc, char** argv, char** env)
|
|||
profile_dump_path = DeprecatedString::formatted("{}.{}.profile", LexicalPath(executable_path).basename(), getpid());
|
||||
|
||||
OwnPtr<Stream> profile_stream;
|
||||
OwnPtr<NonnullOwnPtrVector<DeprecatedString>> profile_strings;
|
||||
OwnPtr<Vector<NonnullOwnPtr<DeprecatedString>>> profile_strings;
|
||||
OwnPtr<Vector<int>> profile_string_id_map;
|
||||
|
||||
if (dump_profile) {
|
||||
|
@ -67,7 +67,7 @@ int main(int argc, char** argv, char** env)
|
|||
return 1;
|
||||
}
|
||||
profile_stream = profile_stream_or_error.release_value();
|
||||
profile_strings = make<NonnullOwnPtrVector<DeprecatedString>>();
|
||||
profile_strings = make<Vector<NonnullOwnPtr<DeprecatedString>>>();
|
||||
profile_string_id_map = make<Vector<int>>();
|
||||
|
||||
profile_stream->write_entire_buffer(R"({"events":[)"sv.bytes()).release_value_but_fixme_should_propagate_errors();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue