diff options
author | Lenny Maiorani <lenny@serenityos.org> | 2022-03-14 13:26:37 -0600 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-03-17 17:23:49 +0000 |
commit | 9c56a83b7600aef977d7cdec567b1b7a0d134ab2 (patch) | |
tree | 79a678b743d1ac227846436d60fd895d8e6fcf04 | |
parent | c37820b898cdb9689debd28f9c66c70a16d3c663 (diff) | |
download | serenity-9c56a83b7600aef977d7cdec567b1b7a0d134ab2.zip |
Libraries: Use default constructors/destructors in LibGfx
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules
"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
31 files changed, 41 insertions, 73 deletions
diff --git a/Userland/Libraries/LibGfx/BMPLoader.cpp b/Userland/Libraries/LibGfx/BMPLoader.cpp index 7008e96dc8..841e50aef6 100644 --- a/Userland/Libraries/LibGfx/BMPLoader.cpp +++ b/Userland/Libraries/LibGfx/BMPLoader.cpp @@ -1307,9 +1307,7 @@ BMPImageDecoderPlugin::BMPImageDecoderPlugin(const u8* data, size_t data_size) m_context->file_size = data_size; } -BMPImageDecoderPlugin::~BMPImageDecoderPlugin() -{ -} +BMPImageDecoderPlugin::~BMPImageDecoderPlugin() = default; IntSize BMPImageDecoderPlugin::size() { diff --git a/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp b/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp index 5b2c35f874..1451e5ba89 100644 --- a/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp +++ b/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp @@ -16,14 +16,6 @@ namespace Gfx { static constexpr int menubar_height = 20; -ClassicWindowTheme::ClassicWindowTheme() -{ -} - -ClassicWindowTheme::~ClassicWindowTheme() -{ -} - Gfx::IntRect ClassicWindowTheme::titlebar_icon_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const { if (window_type == WindowType::ToolWindow) diff --git a/Userland/Libraries/LibGfx/ClassicWindowTheme.h b/Userland/Libraries/LibGfx/ClassicWindowTheme.h index e72e9b90f1..0aaa7f101e 100644 --- a/Userland/Libraries/LibGfx/ClassicWindowTheme.h +++ b/Userland/Libraries/LibGfx/ClassicWindowTheme.h @@ -13,8 +13,8 @@ namespace Gfx { class ClassicWindowTheme final : public WindowTheme { public: - ClassicWindowTheme(); - virtual ~ClassicWindowTheme() override; + ClassicWindowTheme() = default; + virtual ~ClassicWindowTheme() override = default; virtual void paint_normal_frame(Painter& painter, WindowState window_state, const IntRect& window_rect, StringView window_title, const Bitmap& icon, const Palette& palette, const IntRect& leftmost_button_rect, int menu_row_count, bool window_modified) const override; virtual void paint_tool_window_frame(Painter&, WindowState, const IntRect& window_rect, StringView title, const Palette&, const IntRect& leftmost_button_rect) const override; diff --git a/Userland/Libraries/LibGfx/DDSLoader.cpp b/Userland/Libraries/LibGfx/DDSLoader.cpp index 482184ff42..64ef66267b 100644 --- a/Userland/Libraries/LibGfx/DDSLoader.cpp +++ b/Userland/Libraries/LibGfx/DDSLoader.cpp @@ -944,9 +944,7 @@ DDSImageDecoderPlugin::DDSImageDecoderPlugin(const u8* data, size_t size) m_context->data_size = size; } -DDSImageDecoderPlugin::~DDSImageDecoderPlugin() -{ -} +DDSImageDecoderPlugin::~DDSImageDecoderPlugin() = default; IntSize DDSImageDecoderPlugin::size() { diff --git a/Userland/Libraries/LibGfx/DisjointRectSet.h b/Userland/Libraries/LibGfx/DisjointRectSet.h index cafb9157f2..9a256566e8 100644 --- a/Userland/Libraries/LibGfx/DisjointRectSet.h +++ b/Userland/Libraries/LibGfx/DisjointRectSet.h @@ -17,8 +17,8 @@ public: DisjointRectSet(const DisjointRectSet&) = delete; DisjointRectSet& operator=(const DisjointRectSet&) = delete; - DisjointRectSet() { } - ~DisjointRectSet() { } + DisjointRectSet() = default; + ~DisjointRectSet() = default; DisjointRectSet(const IntRect& rect) { diff --git a/Userland/Libraries/LibGfx/Filters/BoxBlurFilter.h b/Userland/Libraries/LibGfx/Filters/BoxBlurFilter.h index f942e0a150..6f69ed0742 100644 --- a/Userland/Libraries/LibGfx/Filters/BoxBlurFilter.h +++ b/Userland/Libraries/LibGfx/Filters/BoxBlurFilter.h @@ -13,8 +13,8 @@ namespace Gfx { template<size_t N> class BoxBlurFilter : public GenericConvolutionFilter<N> { public: - BoxBlurFilter() { } - virtual ~BoxBlurFilter() { } + BoxBlurFilter() = default; + virtual ~BoxBlurFilter() = default; virtual const char* class_name() const override { return "BoxBlurFilter"; } }; diff --git a/Userland/Libraries/LibGfx/Filters/Filter.h b/Userland/Libraries/LibGfx/Filters/Filter.h index d196361abe..558e5695b1 100644 --- a/Userland/Libraries/LibGfx/Filters/Filter.h +++ b/Userland/Libraries/LibGfx/Filters/Filter.h @@ -17,9 +17,9 @@ public: public: virtual bool is_generic_convolution_filter() const { return false; } - virtual ~Parameters() { } + virtual ~Parameters() = default; }; - virtual ~Filter() { } + virtual ~Filter() = default; virtual const char* class_name() const = 0; @@ -27,7 +27,7 @@ public: virtual void apply(Bitmap&, IntRect const&, Bitmap const&, IntRect const&) {}; protected: - Filter() { } + Filter() = default; }; } diff --git a/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h b/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h index c32a25c1ba..76226a2cb5 100644 --- a/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h +++ b/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h @@ -58,8 +58,8 @@ public: RefPtr<Gfx::Bitmap> m_target; }; - GenericConvolutionFilter() { } - virtual ~GenericConvolutionFilter() { } + GenericConvolutionFilter() = default; + virtual ~GenericConvolutionFilter() = default; virtual const char* class_name() const override { return "GenericConvolutionFilter"; } diff --git a/Userland/Libraries/LibGfx/Filters/GrayscaleFilter.h b/Userland/Libraries/LibGfx/Filters/GrayscaleFilter.h index 8671570c2c..eef85f41b8 100644 --- a/Userland/Libraries/LibGfx/Filters/GrayscaleFilter.h +++ b/Userland/Libraries/LibGfx/Filters/GrayscaleFilter.h @@ -12,8 +12,8 @@ namespace Gfx { class GrayscaleFilter : public ColorFilter { public: - GrayscaleFilter() { } - virtual ~GrayscaleFilter() { } + GrayscaleFilter() = default; + virtual ~GrayscaleFilter() = default; virtual char const* class_name() const override { return "GrayscaleFilter"; } diff --git a/Userland/Libraries/LibGfx/Filters/InvertFilter.h b/Userland/Libraries/LibGfx/Filters/InvertFilter.h index 5c50dc0098..347a7aab50 100644 --- a/Userland/Libraries/LibGfx/Filters/InvertFilter.h +++ b/Userland/Libraries/LibGfx/Filters/InvertFilter.h @@ -12,8 +12,8 @@ namespace Gfx { class InvertFilter : public ColorFilter { public: - InvertFilter() { } - virtual ~InvertFilter() { } + InvertFilter() = default; + virtual ~InvertFilter() = default; virtual char const* class_name() const override { return "InvertFilter"; } diff --git a/Userland/Libraries/LibGfx/Filters/LaplacianFilter.h b/Userland/Libraries/LibGfx/Filters/LaplacianFilter.h index 8b84dcca83..0211b2daac 100644 --- a/Userland/Libraries/LibGfx/Filters/LaplacianFilter.h +++ b/Userland/Libraries/LibGfx/Filters/LaplacianFilter.h @@ -12,8 +12,8 @@ namespace Gfx { class LaplacianFilter : public GenericConvolutionFilter<3> { public: - LaplacianFilter() { } - virtual ~LaplacianFilter() { } + LaplacianFilter() = default; + virtual ~LaplacianFilter() = default; virtual const char* class_name() const override { return "LaplacianFilter"; } }; diff --git a/Userland/Libraries/LibGfx/Filters/SepiaFilter.h b/Userland/Libraries/LibGfx/Filters/SepiaFilter.h index da7b1e7319..ce5220c6ef 100644 --- a/Userland/Libraries/LibGfx/Filters/SepiaFilter.h +++ b/Userland/Libraries/LibGfx/Filters/SepiaFilter.h @@ -18,7 +18,7 @@ public: : m_amount(amount) { } - virtual ~SepiaFilter() { } + virtual ~SepiaFilter() = default; virtual char const* class_name() const override { return "SepiaFilter"; } diff --git a/Userland/Libraries/LibGfx/Filters/SharpenFilter.h b/Userland/Libraries/LibGfx/Filters/SharpenFilter.h index 31d0db0fd3..af0d6f9202 100644 --- a/Userland/Libraries/LibGfx/Filters/SharpenFilter.h +++ b/Userland/Libraries/LibGfx/Filters/SharpenFilter.h @@ -12,8 +12,8 @@ namespace Gfx { class SharpenFilter : public GenericConvolutionFilter<3> { public: - SharpenFilter() { } - virtual ~SharpenFilter() { } + SharpenFilter() = default; + virtual ~SharpenFilter() = default; virtual const char* class_name() const override { return "SharpenFilter"; } }; diff --git a/Userland/Libraries/LibGfx/Filters/SpatialGaussianBlurFilter.h b/Userland/Libraries/LibGfx/Filters/SpatialGaussianBlurFilter.h index 1f18f0bae5..a2ca483f51 100644 --- a/Userland/Libraries/LibGfx/Filters/SpatialGaussianBlurFilter.h +++ b/Userland/Libraries/LibGfx/Filters/SpatialGaussianBlurFilter.h @@ -14,8 +14,8 @@ namespace Gfx { template<size_t N, typename = typename EnableIf<N % 2 == 1>::Type> class SpatialGaussianBlurFilter : public GenericConvolutionFilter<N> { public: - SpatialGaussianBlurFilter() { } - virtual ~SpatialGaussianBlurFilter() { } + SpatialGaussianBlurFilter() = default; + virtual ~SpatialGaussianBlurFilter() = default; virtual const char* class_name() const override { return "SpatialGaussianBlurFilter"; } }; diff --git a/Userland/Libraries/LibGfx/FontDatabase.cpp b/Userland/Libraries/LibGfx/FontDatabase.cpp index d184a70bdb..30c1afaf33 100644 --- a/Userland/Libraries/LibGfx/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/FontDatabase.cpp @@ -119,10 +119,6 @@ FontDatabase::FontDatabase() } } -FontDatabase::~FontDatabase() -{ -} - void FontDatabase::for_each_font(Function<void(const Gfx::Font&)> callback) { Vector<RefPtr<Gfx::Font>> fonts; diff --git a/Userland/Libraries/LibGfx/FontDatabase.h b/Userland/Libraries/LibGfx/FontDatabase.h index 5e3a5af819..32b12c7dfc 100644 --- a/Userland/Libraries/LibGfx/FontDatabase.h +++ b/Userland/Libraries/LibGfx/FontDatabase.h @@ -54,7 +54,7 @@ public: private: FontDatabase(); - ~FontDatabase(); + ~FontDatabase() = default; RefPtr<Typeface> get_or_create_typeface(const String& family, const String& variant); diff --git a/Userland/Libraries/LibGfx/GIFLoader.cpp b/Userland/Libraries/LibGfx/GIFLoader.cpp index a715a08bfc..10708a04b8 100644 --- a/Userland/Libraries/LibGfx/GIFLoader.cpp +++ b/Userland/Libraries/LibGfx/GIFLoader.cpp @@ -605,7 +605,7 @@ GIFImageDecoderPlugin::GIFImageDecoderPlugin(const u8* data, size_t size) m_context->data_size = size; } -GIFImageDecoderPlugin::~GIFImageDecoderPlugin() { } +GIFImageDecoderPlugin::~GIFImageDecoderPlugin() = default; IntSize GIFImageDecoderPlugin::size() { diff --git a/Userland/Libraries/LibGfx/ICOLoader.cpp b/Userland/Libraries/LibGfx/ICOLoader.cpp index 3c4edf850d..245b337189 100644 --- a/Userland/Libraries/LibGfx/ICOLoader.cpp +++ b/Userland/Libraries/LibGfx/ICOLoader.cpp @@ -286,7 +286,7 @@ ICOImageDecoderPlugin::ICOImageDecoderPlugin(const u8* data, size_t size) m_context->data_size = size; } -ICOImageDecoderPlugin::~ICOImageDecoderPlugin() { } +ICOImageDecoderPlugin::~ICOImageDecoderPlugin() = default; IntSize ICOImageDecoderPlugin::size() { diff --git a/Userland/Libraries/LibGfx/ImageDecoder.cpp b/Userland/Libraries/LibGfx/ImageDecoder.cpp index e8a772fe5a..8d9720767c 100644 --- a/Userland/Libraries/LibGfx/ImageDecoder.cpp +++ b/Userland/Libraries/LibGfx/ImageDecoder.cpp @@ -79,8 +79,4 @@ ImageDecoder::ImageDecoder(NonnullOwnPtr<ImageDecoderPlugin> plugin) { } -ImageDecoder::~ImageDecoder() -{ -} - } diff --git a/Userland/Libraries/LibGfx/ImageDecoder.h b/Userland/Libraries/LibGfx/ImageDecoder.h index 62a164921d..431a26fd7e 100644 --- a/Userland/Libraries/LibGfx/ImageDecoder.h +++ b/Userland/Libraries/LibGfx/ImageDecoder.h @@ -27,7 +27,7 @@ struct ImageFrameDescriptor { class ImageDecoderPlugin { public: - virtual ~ImageDecoderPlugin() { } + virtual ~ImageDecoderPlugin() = default; virtual IntSize size() = 0; @@ -42,13 +42,13 @@ public: virtual ErrorOr<ImageFrameDescriptor> frame(size_t index) = 0; protected: - ImageDecoderPlugin() { } + ImageDecoderPlugin() = default; }; class ImageDecoder : public RefCounted<ImageDecoder> { public: static RefPtr<ImageDecoder> try_create(ReadonlyBytes); - ~ImageDecoder(); + ~ImageDecoder() = default; IntSize size() const { return m_plugin->size(); } int width() const { return size().width(); } diff --git a/Userland/Libraries/LibGfx/JPGLoader.cpp b/Userland/Libraries/LibGfx/JPGLoader.cpp index 6c31590c47..2ff7f82aee 100644 --- a/Userland/Libraries/LibGfx/JPGLoader.cpp +++ b/Userland/Libraries/LibGfx/JPGLoader.cpp @@ -1232,9 +1232,7 @@ JPGImageDecoderPlugin::JPGImageDecoderPlugin(const u8* data, size_t size) m_context->huffman_stream.stream.ensure_capacity(50 * KiB); } -JPGImageDecoderPlugin::~JPGImageDecoderPlugin() -{ -} +JPGImageDecoderPlugin::~JPGImageDecoderPlugin() = default; IntSize JPGImageDecoderPlugin::size() { diff --git a/Userland/Libraries/LibGfx/Line.h b/Userland/Libraries/LibGfx/Line.h index 327644a51f..f1438cd1b5 100644 --- a/Userland/Libraries/LibGfx/Line.h +++ b/Userland/Libraries/LibGfx/Line.h @@ -19,7 +19,7 @@ namespace Gfx { template<typename T> class Line { public: - Line() { } + Line() = default; Line(Point<T> a, Point<T> b) : m_a(a) diff --git a/Userland/Libraries/LibGfx/PNGLoader.cpp b/Userland/Libraries/LibGfx/PNGLoader.cpp index 42eb76268e..e95f8edc02 100644 --- a/Userland/Libraries/LibGfx/PNGLoader.cpp +++ b/Userland/Libraries/LibGfx/PNGLoader.cpp @@ -918,9 +918,7 @@ PNGImageDecoderPlugin::PNGImageDecoderPlugin(const u8* data, size_t size) m_context->data_size = size; } -PNGImageDecoderPlugin::~PNGImageDecoderPlugin() -{ -} +PNGImageDecoderPlugin::~PNGImageDecoderPlugin() = default; IntSize PNGImageDecoderPlugin::size() { diff --git a/Userland/Libraries/LibGfx/PNGWriter.h b/Userland/Libraries/LibGfx/PNGWriter.h index bc7b110b48..a2653d7cd0 100644 --- a/Userland/Libraries/LibGfx/PNGWriter.h +++ b/Userland/Libraries/LibGfx/PNGWriter.h @@ -19,7 +19,7 @@ public: static ByteBuffer encode(Gfx::Bitmap const&); private: - PNGWriter() { } + PNGWriter() = default; Vector<u8> m_data; void add_chunk(PNGChunk&); diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 170c57cd0f..77bacd4309 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -72,10 +72,6 @@ Painter::Painter(Gfx::Bitmap& bitmap) m_clip_origin = state().clip_rect; } -Painter::~Painter() -{ -} - void Painter::fill_rect_with_draw_op(IntRect const& a_rect, Color color) { VERIFY(scale() == 1); // FIXME: Add scaling support. diff --git a/Userland/Libraries/LibGfx/Painter.h b/Userland/Libraries/LibGfx/Painter.h index 2e23b63e9f..9bb7650c55 100644 --- a/Userland/Libraries/LibGfx/Painter.h +++ b/Userland/Libraries/LibGfx/Painter.h @@ -26,7 +26,7 @@ namespace Gfx { class Painter { public: explicit Painter(Gfx::Bitmap&); - ~Painter(); + ~Painter() = default; enum class LineStyle { Solid, diff --git a/Userland/Libraries/LibGfx/Path.h b/Userland/Libraries/LibGfx/Path.h index 5519bc959f..cad1c88099 100644 --- a/Userland/Libraries/LibGfx/Path.h +++ b/Userland/Libraries/LibGfx/Path.h @@ -143,7 +143,7 @@ private: class Path { public: - Path() { } + Path() = default; void move_to(const FloatPoint& point) { diff --git a/Userland/Libraries/LibGfx/ShareableBitmap.h b/Userland/Libraries/LibGfx/ShareableBitmap.h index 4601c93224..3eefade8ac 100644 --- a/Userland/Libraries/LibGfx/ShareableBitmap.h +++ b/Userland/Libraries/LibGfx/ShareableBitmap.h @@ -14,7 +14,7 @@ namespace Gfx { class ShareableBitmap { public: - ShareableBitmap() { } + ShareableBitmap() = default; enum Tag { ConstructWithKnownGoodBitmap }; ShareableBitmap(NonnullRefPtr<Gfx::Bitmap>, Tag); diff --git a/Userland/Libraries/LibGfx/StylePainter.h b/Userland/Libraries/LibGfx/StylePainter.h index c3f876b89f..76cc10e66b 100644 --- a/Userland/Libraries/LibGfx/StylePainter.h +++ b/Userland/Libraries/LibGfx/StylePainter.h @@ -34,7 +34,7 @@ enum class FrameShape { // FIXME: should this be in its own header? class BaseStylePainter { public: - virtual ~BaseStylePainter() { } + virtual ~BaseStylePainter() = default; virtual void paint_button(Painter&, IntRect const&, Palette const&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true, bool focused = false, bool default_button = false) = 0; virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, bool top, bool in_active_window) = 0; @@ -47,7 +47,7 @@ public: virtual void paint_simple_rect_shadow(Painter&, IntRect const&, Bitmap const& shadow_bitmap, bool shadow_includes_frame = false, bool fill_content = false) = 0; protected: - BaseStylePainter() { } + BaseStylePainter() = default; }; class StylePainter { diff --git a/Userland/Libraries/LibGfx/WindowTheme.cpp b/Userland/Libraries/LibGfx/WindowTheme.cpp index 6f686ece63..491fd45192 100644 --- a/Userland/Libraries/LibGfx/WindowTheme.cpp +++ b/Userland/Libraries/LibGfx/WindowTheme.cpp @@ -15,8 +15,4 @@ WindowTheme& WindowTheme::current() return theme; } -WindowTheme::~WindowTheme() -{ -} - } diff --git a/Userland/Libraries/LibGfx/WindowTheme.h b/Userland/Libraries/LibGfx/WindowTheme.h index 29bf0049a8..d307099983 100644 --- a/Userland/Libraries/LibGfx/WindowTheme.h +++ b/Userland/Libraries/LibGfx/WindowTheme.h @@ -27,7 +27,7 @@ public: Moving, }; - virtual ~WindowTheme(); + virtual ~WindowTheme() = default; static WindowTheme& current(); @@ -50,7 +50,7 @@ public: virtual float frame_alpha_hit_threshold(WindowState) const = 0; protected: - WindowTheme() { } + WindowTheme() = default; }; } |