diff --git a/Userland/DevTools/Profiler/DisassemblyModel.cpp b/Userland/DevTools/Profiler/DisassemblyModel.cpp index 020b4e7037..bb6ae0c9ab 100644 --- a/Userland/DevTools/Profiler/DisassemblyModel.cpp +++ b/Userland/DevTools/Profiler/DisassemblyModel.cpp @@ -17,7 +17,7 @@ namespace Profiler { -static const Gfx::Bitmap& heat_gradient() +static Gfx::Bitmap const& heat_gradient() { static RefPtr bitmap; if (!bitmap) { @@ -54,8 +54,8 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node) , m_node(node) { FlatPtr base_address = 0; - const Debug::DebugInfo* debug_info; - const ELF::Image* elf; + Debug::DebugInfo const* debug_info; + ELF::Image const* elf; if (auto maybe_kernel_base = Symbolication::kernel_base(); maybe_kernel_base.has_value() && m_node.address() >= *maybe_kernel_base) { if (!g_kernel_debuginfo_object.has_value()) return; @@ -107,7 +107,7 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node) auto view = symbol.value().raw_data().substring_view(symbol_offset_from_function_start); X86::ELFSymbolProvider symbol_provider(*elf, base_address); - X86::SimpleInstructionStream stream((const u8*)view.characters_without_null_termination(), view.length()); + X86::SimpleInstructionStream stream((u8 const*)view.characters_without_null_termination(), view.length()); X86::Disassembler disassembler(stream); size_t offset_into_symbol = 0; @@ -143,7 +143,7 @@ DisassemblyModel::~DisassemblyModel() { } -int DisassemblyModel::row_count(const GUI::ModelIndex&) const +int DisassemblyModel::row_count(GUI::ModelIndex const&) const { return m_instructions.size(); } @@ -172,7 +172,7 @@ struct ColorPair { Color foreground; }; -static Optional color_pair_for(const InstructionData& insn) +static Optional color_pair_for(InstructionData const& insn) { if (insn.percent == 0) return {}; @@ -186,7 +186,7 @@ static Optional color_pair_for(const InstructionData& insn) return ColorPair { background, foreground }; } -GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const +GUI::Variant DisassemblyModel::data(GUI::ModelIndex const& index, GUI::ModelRole role) const { auto const& insn = m_instructions[index.row()]; diff --git a/Userland/DevTools/Profiler/DisassemblyModel.h b/Userland/DevTools/Profiler/DisassemblyModel.h index 2889435d7f..4dae093fd8 100644 --- a/Userland/DevTools/Profiler/DisassemblyModel.h +++ b/Userland/DevTools/Profiler/DisassemblyModel.h @@ -43,10 +43,10 @@ public: virtual ~DisassemblyModel() override; - virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; - virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; } + virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override; + virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Count; } virtual String column_name(int) const override; - virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override; + virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override; virtual bool is_column_sortable(int) const override { return false; } private: diff --git a/Userland/DevTools/Profiler/FlameGraphView.cpp b/Userland/DevTools/Profiler/FlameGraphView.cpp index d19daa0a69..2bae62c503 100644 --- a/Userland/DevTools/Profiler/FlameGraphView.cpp +++ b/Userland/DevTools/Profiler/FlameGraphView.cpp @@ -123,7 +123,7 @@ void FlameGraphView::paint_event(GUI::PaintEvent& event) GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); - for (const auto& bar : m_bars) { + for (auto const& bar : m_bars) { auto label = bar_label(bar); auto color = m_colors[label.hash() % m_colors.size()]; diff --git a/Userland/DevTools/Profiler/IndividualSampleModel.cpp b/Userland/DevTools/Profiler/IndividualSampleModel.cpp index 9b12620a25..a4961c01c1 100644 --- a/Userland/DevTools/Profiler/IndividualSampleModel.cpp +++ b/Userland/DevTools/Profiler/IndividualSampleModel.cpp @@ -21,13 +21,13 @@ IndividualSampleModel::~IndividualSampleModel() { } -int IndividualSampleModel::row_count(const GUI::ModelIndex&) const +int IndividualSampleModel::row_count(GUI::ModelIndex const&) const { auto const& event = m_profile.events().at(m_event_index); return event.frames.size(); } -int IndividualSampleModel::column_count(const GUI::ModelIndex&) const +int IndividualSampleModel::column_count(GUI::ModelIndex const&) const { return Column::__Count; } @@ -46,7 +46,7 @@ String IndividualSampleModel::column_name(int column) const } } -GUI::Variant IndividualSampleModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const +GUI::Variant IndividualSampleModel::data(GUI::ModelIndex const& index, GUI::ModelRole role) const { auto const& event = m_profile.events().at(m_event_index); auto const& frame = event.frames[event.frames.size() - index.row() - 1]; diff --git a/Userland/DevTools/Profiler/IndividualSampleModel.h b/Userland/DevTools/Profiler/IndividualSampleModel.h index 567830d34f..1f1f2435cb 100644 --- a/Userland/DevTools/Profiler/IndividualSampleModel.h +++ b/Userland/DevTools/Profiler/IndividualSampleModel.h @@ -28,16 +28,16 @@ public: virtual ~IndividualSampleModel() override; - virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; - virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override; + virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override; virtual String column_name(int) const override; - virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override; + virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override; private: IndividualSampleModel(Profile&, size_t event_index); Profile& m_profile; - const size_t m_event_index { 0 }; + size_t const m_event_index { 0 }; }; } diff --git a/Userland/DevTools/Profiler/Process.cpp b/Userland/DevTools/Profiler/Process.cpp index 1d46c6323e..81ea70facc 100644 --- a/Userland/DevTools/Profiler/Process.cpp +++ b/Userland/DevTools/Profiler/Process.cpp @@ -43,7 +43,7 @@ void Process::handle_thread_exit(pid_t tid, EventSerialNumber serial) HashMap> g_mapped_object_cache; -static MappedObject* get_or_create_mapped_object(const String& path) +static MappedObject* get_or_create_mapped_object(String const& path) { if (auto it = g_mapped_object_cache.find(path); it != g_mapped_object_cache.end()) return it->value.ptr(); @@ -67,7 +67,7 @@ static MappedObject* get_or_create_mapped_object(const String& path) return ptr; } -void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, const String& name) +void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, String const& name) { StringView path; if (name.contains("Loader.so"sv)) @@ -107,7 +107,7 @@ void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, const String& name) } } -const Debug::DebugInfo& LibraryMetadata::Library::load_debug_info(FlatPtr base_address) const +Debug::DebugInfo const& LibraryMetadata::Library::load_debug_info(FlatPtr base_address) const { if (debug_info == nullptr) debug_info = make(object->elf, String::empty(), base_address); @@ -122,7 +122,7 @@ String LibraryMetadata::Library::symbolicate(FlatPtr ptr, u32* offset) const return object->elf.symbolicate(ptr - base, offset); } -const LibraryMetadata::Library* LibraryMetadata::library_containing(FlatPtr ptr) const +LibraryMetadata::Library const* LibraryMetadata::library_containing(FlatPtr ptr) const { for (auto& it : m_libraries) { auto& library = *it.value; diff --git a/Userland/DevTools/Profiler/Process.h b/Userland/DevTools/Profiler/Process.h index d63d2a7c61..3d059d1e66 100644 --- a/Userland/DevTools/Profiler/Process.h +++ b/Userland/DevTools/Profiler/Process.h @@ -34,11 +34,11 @@ public: mutable OwnPtr debug_info; String symbolicate(FlatPtr, u32* offset) const; - const Debug::DebugInfo& load_debug_info(FlatPtr base_address) const; + Debug::DebugInfo const& load_debug_info(FlatPtr base_address) const; }; - void handle_mmap(FlatPtr base, size_t size, const String& name); - const Library* library_containing(FlatPtr) const; + void handle_mmap(FlatPtr base, size_t size, String const& name); + Library const* library_containing(FlatPtr) const; private: mutable HashMap> m_libraries; diff --git a/Userland/DevTools/Profiler/Profile.cpp b/Userland/DevTools/Profiler/Profile.cpp index 3b3df1025c..b1bffb4529 100644 --- a/Userland/DevTools/Profiler/Profile.cpp +++ b/Userland/DevTools/Profiler/Profile.cpp @@ -145,7 +145,7 @@ void Profile::rebuild_tree() ProfileNode* node = nullptr; auto& process_node = find_or_create_process_node(event.pid, event.serial); process_node.increment_event_count(); - for_each_frame([&](const Frame& frame, bool is_innermost_frame) { + for_each_frame([&](Frame const& frame, bool is_innermost_frame) { auto const& object_name = frame.object_name; auto const& symbol = frame.symbol; auto const& address = frame.address; @@ -538,7 +538,7 @@ void Profile::set_show_percentages(bool show_percentages) m_show_percentages = show_percentages; } -void Profile::set_disassembly_index(const GUI::ModelIndex& index) +void Profile::set_disassembly_index(GUI::ModelIndex const& index) { if (m_disassembly_index == index) return; diff --git a/Userland/DevTools/Profiler/Profile.h b/Userland/DevTools/Profiler/Profile.h index 78ff901eab..6e46127f3b 100644 --- a/Userland/DevTools/Profiler/Profile.h +++ b/Userland/DevTools/Profiler/Profile.h @@ -52,8 +52,8 @@ public: bool has_seen_event(size_t event_index) const { return m_seen_events.get(event_index); } void did_see_event(size_t event_index) { m_seen_events.set(event_index, true); } - const FlyString& object_name() const { return m_object_name; } - const String& symbol() const { return m_symbol; } + FlyString const& object_name() const { return m_object_name; } + String const& symbol() const { return m_symbol; } FlatPtr address() const { return m_address; } u32 offset() const { return m_offset; } u64 timestamp() const { return m_timestamp; } @@ -62,7 +62,7 @@ public: u32 self_count() const { return m_self_count; } int child_count() const { return m_children.size(); } - const Vector>& children() const { return m_children; } + Vector> const& children() const { return m_children; } void add_child(ProfileNode& child) { @@ -87,14 +87,14 @@ public: }; ProfileNode* parent() { return m_parent; } - const ProfileNode* parent() const { return m_parent; } + ProfileNode const* parent() const { return m_parent; } void increment_event_count() { ++m_event_count; } void increment_self_count() { ++m_self_count; } void sort_children(); - const HashMap& events_per_address() const { return m_events_per_address; } + HashMap const& events_per_address() const { return m_events_per_address; } void add_event_address(FlatPtr address) { auto it = m_events_per_address.find(address); @@ -150,7 +150,7 @@ public: GUI::Model* disassembly_model(); GUI::Model* source_model(); - const Process* find_process(pid_t pid, EventSerialNumber serial) const + Process const* find_process(pid_t pid, EventSerialNumber serial) const { auto it = m_processes.find_if([&pid, &serial](auto& entry) { return entry.pid == pid && entry.valid_at(serial); @@ -158,10 +158,10 @@ public: return it.is_end() ? nullptr : &(*it); } - void set_disassembly_index(const GUI::ModelIndex&); - void set_source_index(const GUI::ModelIndex&); + void set_disassembly_index(GUI::ModelIndex const&); + void set_source_index(GUI::ModelIndex const&); - const Vector>& roots() const { return m_roots; } + Vector> const& roots() const { return m_roots; } struct Frame { FlyString object_name; @@ -225,8 +225,8 @@ public: }; Vector const& events() const { return m_events; } - const Vector& filtered_event_indices() const { return m_filtered_event_indices; } - const Vector& filtered_signpost_indices() const { return m_filtered_signpost_indices; } + Vector const& filtered_event_indices() const { return m_filtered_event_indices; } + Vector const& filtered_signpost_indices() const { return m_filtered_signpost_indices; } u64 length_in_ms() const { return m_last_timestamp - m_first_timestamp; } u64 first_timestamp() const { return m_first_timestamp; } @@ -250,7 +250,7 @@ public: bool show_percentages() const { return m_show_percentages; } void set_show_percentages(bool); - const Vector& processes() const { return m_processes; } + Vector const& processes() const { return m_processes; } template void for_each_event_in_filter_range(Callback callback) diff --git a/Userland/DevTools/Profiler/ProfileModel.cpp b/Userland/DevTools/Profiler/ProfileModel.cpp index c0f170fd2c..c3ffa609db 100644 --- a/Userland/DevTools/Profiler/ProfileModel.cpp +++ b/Userland/DevTools/Profiler/ProfileModel.cpp @@ -23,7 +23,7 @@ ProfileModel::~ProfileModel() { } -GUI::ModelIndex ProfileModel::index(int row, int column, const GUI::ModelIndex& parent) const +GUI::ModelIndex ProfileModel::index(int row, int column, GUI::ModelIndex const& parent) const { if (!parent.is_valid()) { if (m_profile.roots().is_empty()) @@ -34,7 +34,7 @@ GUI::ModelIndex ProfileModel::index(int row, int column, const GUI::ModelIndex& return create_index(row, column, remote_parent.children().at(row).ptr()); } -GUI::ModelIndex ProfileModel::parent_index(const GUI::ModelIndex& index) const +GUI::ModelIndex ProfileModel::parent_index(GUI::ModelIndex const& index) const { if (!index.is_valid()) return {}; @@ -62,7 +62,7 @@ GUI::ModelIndex ProfileModel::parent_index(const GUI::ModelIndex& index) const return {}; } -int ProfileModel::row_count(const GUI::ModelIndex& index) const +int ProfileModel::row_count(GUI::ModelIndex const& index) const { if (!index.is_valid()) return m_profile.roots().size(); @@ -70,7 +70,7 @@ int ProfileModel::row_count(const GUI::ModelIndex& index) const return node.children().size(); } -int ProfileModel::column_count(const GUI::ModelIndex&) const +int ProfileModel::column_count(GUI::ModelIndex const&) const { return Column::__Count; } @@ -94,7 +94,7 @@ String ProfileModel::column_name(int column) const } } -GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const +GUI::Variant ProfileModel::data(GUI::ModelIndex const& index, GUI::ModelRole role) const { auto* node = static_cast(index.internal_data()); if (role == GUI::ModelRole::TextAlignment) { diff --git a/Userland/DevTools/Profiler/ProfileModel.h b/Userland/DevTools/Profiler/ProfileModel.h index d046414790..5f938f09b1 100644 --- a/Userland/DevTools/Profiler/ProfileModel.h +++ b/Userland/DevTools/Profiler/ProfileModel.h @@ -30,12 +30,12 @@ public: virtual ~ProfileModel() override; - virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; - virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override; + virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override; virtual String column_name(int) const override; - virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override; - virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override; - virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override; + virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override; + virtual GUI::ModelIndex index(int row, int column, GUI::ModelIndex const& parent = GUI::ModelIndex()) const override; + virtual GUI::ModelIndex parent_index(GUI::ModelIndex const&) const override; virtual int tree_column() const override { return Column::StackFrame; } virtual bool is_column_sortable(int) const override { return false; } virtual bool is_searchable() const override { return true; } diff --git a/Userland/DevTools/Profiler/SamplesModel.cpp b/Userland/DevTools/Profiler/SamplesModel.cpp index c4821703d7..7f0890e087 100644 --- a/Userland/DevTools/Profiler/SamplesModel.cpp +++ b/Userland/DevTools/Profiler/SamplesModel.cpp @@ -21,12 +21,12 @@ SamplesModel::~SamplesModel() { } -int SamplesModel::row_count(const GUI::ModelIndex&) const +int SamplesModel::row_count(GUI::ModelIndex const&) const { return m_profile.filtered_event_indices().size(); } -int SamplesModel::column_count(const GUI::ModelIndex&) const +int SamplesModel::column_count(GUI::ModelIndex const&) const { return Column::__Count; } @@ -53,7 +53,7 @@ String SamplesModel::column_name(int column) const } } -GUI::Variant SamplesModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const +GUI::Variant SamplesModel::data(GUI::ModelIndex const& index, GUI::ModelRole role) const { u32 event_index = m_profile.filtered_event_indices()[index.row()]; auto const& event = m_profile.events().at(event_index); diff --git a/Userland/DevTools/Profiler/SamplesModel.h b/Userland/DevTools/Profiler/SamplesModel.h index 5d190e9e0c..f40702cb31 100644 --- a/Userland/DevTools/Profiler/SamplesModel.h +++ b/Userland/DevTools/Profiler/SamplesModel.h @@ -32,10 +32,10 @@ public: virtual ~SamplesModel() override; - virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; - virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override; + virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override; virtual String column_name(int) const override; - virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override; + virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override; virtual bool is_column_sortable(int) const override { return false; } private: diff --git a/Userland/DevTools/Profiler/SignpostsModel.cpp b/Userland/DevTools/Profiler/SignpostsModel.cpp index e24a477c1f..3afcc0339a 100644 --- a/Userland/DevTools/Profiler/SignpostsModel.cpp +++ b/Userland/DevTools/Profiler/SignpostsModel.cpp @@ -19,12 +19,12 @@ SignpostsModel::~SignpostsModel() { } -int SignpostsModel::row_count(const GUI::ModelIndex&) const +int SignpostsModel::row_count(GUI::ModelIndex const&) const { return m_profile.filtered_signpost_indices().size(); } -int SignpostsModel::column_count(const GUI::ModelIndex&) const +int SignpostsModel::column_count(GUI::ModelIndex const&) const { return Column::__Count; } @@ -51,7 +51,7 @@ String SignpostsModel::column_name(int column) const } } -GUI::Variant SignpostsModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const +GUI::Variant SignpostsModel::data(GUI::ModelIndex const& index, GUI::ModelRole role) const { u32 event_index = m_profile.filtered_signpost_indices()[index.row()]; auto const& event = m_profile.events().at(event_index); diff --git a/Userland/DevTools/Profiler/SignpostsModel.h b/Userland/DevTools/Profiler/SignpostsModel.h index 5162c30694..b9660ea76b 100644 --- a/Userland/DevTools/Profiler/SignpostsModel.h +++ b/Userland/DevTools/Profiler/SignpostsModel.h @@ -32,10 +32,10 @@ public: virtual ~SignpostsModel() override; - virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; - virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override; + virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override; virtual String column_name(int) const override; - virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override; + virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override; virtual bool is_column_sortable(int) const override { return false; } private: diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index bb34effc92..59ace5eee7 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -46,7 +46,7 @@ static bool generate_profile(pid_t& pid); ErrorOr serenity_main(Main::Arguments arguments) { int pid = 0; - const char* perfcore_file_arg = nullptr; + char const* perfcore_file_arg = nullptr; Core::ArgsParser args_parser; args_parser.add_option(pid, "PID to profile", "pid", 'p', "PID"); args_parser.add_positional_argument(perfcore_file_arg, "Path of perfcore file", "perfcore-file", Core::ArgsParser::Required::No); @@ -190,7 +190,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto individual_sample_view = TRY(samples_splitter->try_add()); samples_table_view->on_selection_change = [&] { - const auto& index = samples_table_view->selection().first(); + auto const& index = samples_table_view->selection().first(); auto model = IndividualSampleModel::create(*profile, index.data(GUI::ModelRole::Custom).to_integer()); individual_sample_view->set_model(move(model)); }; @@ -205,7 +205,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto individual_signpost_view = TRY(signposts_splitter->try_add()); signposts_table_view->on_selection_change = [&] { - const auto& index = signposts_table_view->selection().first(); + auto const& index = signposts_table_view->selection().first(); auto model = IndividualSampleModel::create(*profile, index.data(GUI::ModelRole::Custom).to_integer()); individual_signpost_view->set_model(move(model)); }; @@ -216,9 +216,9 @@ ErrorOr serenity_main(Main::Arguments arguments) auto flamegraph_view = TRY(flamegraph_tab->try_add(profile->model(), ProfileModel::Column::StackFrame, ProfileModel::Column::SampleCount)); - const u64 start_of_trace = profile->first_timestamp(); - const u64 end_of_trace = start_of_trace + profile->length_in_ms(); - const auto clamp_timestamp = [start_of_trace, end_of_trace](u64 timestamp) -> u64 { + u64 const start_of_trace = profile->first_timestamp(); + u64 const end_of_trace = start_of_trace + profile->length_in_ms(); + auto const clamp_timestamp = [start_of_trace, end_of_trace](u64 timestamp) -> u64 { return min(end_of_trace, max(timestamp, start_of_trace)); }; @@ -291,7 +291,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return app->exec(); } -static bool prompt_to_stop_profiling(pid_t pid, const String& process_name) +static bool prompt_to_stop_profiling(pid_t pid, String const& process_name) { auto window = GUI::Window::construct(); window->set_title(String::formatted("Profiling {}({})", process_name, pid));