diff options
author | Andreas Kling <kling@serenityos.org> | 2022-09-30 17:59:41 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-09-30 18:00:55 +0200 |
commit | 30815c25a20b4bb6a9f7943badb244cbe60b3483 (patch) | |
tree | a9144e933c6fad4876a4b2a3e7a7599c95e4c5f6 /Userland/Libraries/LibGUI/Widget.h | |
parent | 1cff5fe2ffa9dc0c922263e95cb62563ef9a1887 (diff) | |
download | serenity-30815c25a20b4bb6a9f7943badb244cbe60b3483.zip |
LibCore+LibGUI: Make it fast to check if a Core::Object is a Widget
This check happens very often in LibGUI code. 25% of time spent
layouting the emoji input dialog was wasted on RTTI. Adding a simple
fast_is<Widget>() melts almost all of that away.
Diffstat (limited to 'Userland/Libraries/LibGUI/Widget.h')
-rw-r--r-- | Userland/Libraries/LibGUI/Widget.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h index c90672ebd4..04567e6f05 100644 --- a/Userland/Libraries/LibGUI/Widget.h +++ b/Userland/Libraries/LibGUI/Widget.h @@ -404,6 +404,8 @@ protected: void show_or_hide_tooltip(); private: + virtual bool is_widget() const final { return true; } + void handle_paint_event(PaintEvent&); void handle_resize_event(ResizeEvent&); void handle_mousedown_event(MouseEvent&); @@ -467,5 +469,8 @@ inline Widget const* Widget::parent_widget() const } template<> +inline bool Core::Object::fast_is<GUI::Widget>() const { return is_widget(); } + +template<> struct AK::Formatter<GUI::Widget> : AK::Formatter<Core::Object> { }; |