]> git.tdb.fi Git - libs/gui.git/commitdiff
Use lambdas for comparison functions
authorMikko Rasa <tdb@tdb.fi>
Sun, 27 Nov 2022 14:27:36 +0000 (16:27 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 27 Nov 2022 14:27:36 +0000 (16:27 +0200)
source/graphics/imageloader.cpp
source/graphics/imageloader.h
source/graphics/x11/display.cpp

index 64033661360741443185bc9fe004d1da85953dfb..55d2dfb1b8f8c3f4cab2ebd3c9bcd93a0a0e547e 100644 (file)
@@ -58,7 +58,9 @@ ImageLoader *ImageLoader::open_io(IO::Seekable &io)
        if(registry.changed)
        {
                registry.changed = false;
-               sort(registry.loaders, signature_size_compare);
+               sort(registry.loaders,  [](RegisterBase *r1, RegisterBase *r2){
+                       return r1->get_signature_size()<r2->get_signature_size();
+               });
        }
 
        if(registry.loaders.empty())
@@ -131,11 +133,6 @@ ImageLoader::Registry &ImageLoader::get_registry()
        return registry;
 }
 
-bool ImageLoader::signature_size_compare(RegisterBase *r1, RegisterBase *r2)
-{
-       return r1->get_signature_size()<r2->get_signature_size();
-}
-
 
 ImageLoader::Registry::~Registry()
 {
index 53c9e7b7c88ffe04c5fc5ad098cc14ac7acafaf2..64a741089d957d95d1bfc9574ae9efc214f78bb3 100644 (file)
@@ -85,8 +85,6 @@ public:
        static void register_loader();
 private:
        static Registry &get_registry();
-
-       static bool signature_size_compare(RegisterBase *, RegisterBase *);
 };
 
 template<typename T>
index 60c2182b9f5f09093f4fb89317b9174d1a5cbb1e..482e1c34383a073dc9571a5eb957a6c0a93a582d 100644 (file)
@@ -61,15 +61,6 @@ inline Rotation rotation_to_sys(Msp::Graphics::VideoRotation r)
        default: return RR_Rotate_0;
        }
 }
-
-inline bool monitor_x_compare(const Msp::Graphics::Monitor &m1, const Msp::Graphics::Monitor &m2)
-{
-       if(m1.desktop_settings.mode && !m2.desktop_settings.mode)
-               return true;
-       if(!m1.desktop_settings.mode && m2.desktop_settings.mode)
-               return false;
-       return m1.desktop_settings.x<m2.desktop_settings.x;
-}
 #endif
 
 inline unsigned mode_width(const Msp::Graphics::VideoMode &m, Msp::Graphics::VideoRotation r)
@@ -211,7 +202,13 @@ Display::Display(const string &disp_name):
                                monitors[i].current_settings = monitors[i].desktop_settings;
                        }
 
-                       sort(monitors, monitor_x_compare);
+                       sort(monitors, [](const Msp::Graphics::Monitor &m1, const Msp::Graphics::Monitor &m2){
+                               if(m1.desktop_settings.mode && !m2.desktop_settings.mode)
+                                       return true;
+                               if(!m1.desktop_settings.mode && m2.desktop_settings.mode)
+                                       return false;
+                               return m1.desktop_settings.x<m2.desktop_settings.x;
+                       });
 
                        for(unsigned i=0; i<modes.size(); ++i)
                        {