Remove redundant GdkRGBA memcpy
authorArkadiy Illarionov <qarkai@gmail.com>
Fri, 16 Feb 2024 20:56:43 +0000 (23:56 +0300)
committerColin Clark <colin.clark@cclark.uk>
Sun, 18 Feb 2024 10:50:22 +0000 (10:50 +0000)
src/collect-table.cc
src/dupe.cc
src/view-dir.cc
src/view-file/view-file-icon.cc
src/view-file/view-file-list.cc

index 12f38f5..dda4dc7 100644 (file)
@@ -2510,9 +2510,7 @@ static void collection_table_cell_data_cb(GtkTreeViewColumn *, GtkCellRenderer *
        gchar *display_text = nullptr;
        gchar *star_rating = nullptr;
        GdkRGBA color_bg;
-       GdkRGBA color_bg_style;
        GdkRGBA color_fg;
-       GdkRGBA color_fg_style;
        GList *list;
        GtkStyle *style;
 
@@ -2532,22 +2530,13 @@ static void collection_table_cell_data_cb(GtkTreeViewColumn *, GtkCellRenderer *
        style = gtk_widget_get_style(ct->listview);
        if (info && (info->flag_mask & SELECTION_SELECTED) )
                {
-               convert_gdkcolor_to_gdkrgba(&style->text[GTK_STATE_SELECTED], &color_fg_style);
-               convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_SELECTED], &color_bg_style);
-
-               memcpy(&color_fg, &color_fg_style, sizeof(color_fg));
-               memcpy(&color_bg, &color_bg_style, sizeof(color_bg));
+               convert_gdkcolor_to_gdkrgba(&style->text[GTK_STATE_SELECTED], &color_fg);
+               convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_SELECTED], &color_bg);
                }
        else
                {
-               convert_gdkcolor_to_gdkrgba(&style->text[GTK_STATE_NORMAL], &color_fg_style);
-               convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_NORMAL], &color_bg_style);
-
-               memcpy(&color_fg, &color_fg_style, sizeof(color_fg));
-               memcpy(&color_bg, &color_bg_style, sizeof(color_bg));
-
-               memcpy(&color_fg, &color_fg_style, sizeof(color_fg));
-               memcpy(&color_bg, &color_bg_style, sizeof(color_bg));
+               convert_gdkcolor_to_gdkrgba(&style->text[GTK_STATE_NORMAL], &color_fg);
+               convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_NORMAL], &color_bg);
                }
 
        if (info && (info->flag_mask & SELECTION_PRELIGHT))
index 3938978..4eb5b66 100644 (file)
@@ -3997,7 +3997,6 @@ void cell_renderer_height_override(GtkCellRenderer *renderer)
 static GdkRGBA *dupe_listview_color_shifted(GtkWidget *widget)
 {
        static GdkRGBA color;
-       static GdkRGBA color_style;
        static GtkWidget *done = nullptr;
 
        if (done != widget)
@@ -4005,9 +4004,8 @@ static GdkRGBA *dupe_listview_color_shifted(GtkWidget *widget)
                GtkStyle *style;
 
                style = gtk_widget_get_style(widget);
-               convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_NORMAL], &color_style);
+               convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_NORMAL], &color);
 
-               memcpy(&color, &color_style, sizeof(color));
                shift_color(&color, -1, 0);
                done = widget;
                }
index 43eb793..afdd1b6 100644 (file)
@@ -1176,7 +1176,6 @@ void vd_activate_cb(GtkTreeView *tview, GtkTreePath *tpath, GtkTreeViewColumn *,
 static GdkRGBA *vd_color_shifted(GtkWidget *widget)
 {
        static GdkRGBA color;
-       static GdkRGBA color_style;
        static GtkWidget *done = nullptr;
 
 #ifdef HAVE_GTK4
@@ -1187,9 +1186,7 @@ static GdkRGBA *vd_color_shifted(GtkWidget *widget)
                GtkStyleContext *style_context;
 
                style_context = gtk_widget_get_style_context(widget);
-               gtk_style_context_get_background_color(style_context, GTK_STATE_FLAG_NORMAL, &color_style);
-
-               memcpy(&color, &color_style, sizeof(color_style));
+               gtk_style_context_get_background_color(style_context, GTK_STATE_FLAG_NORMAL, &color);
 
                shift_color(&color, -1, 0);
                done = widget;
index ae27a33..b22a646 100644 (file)
@@ -2100,8 +2100,6 @@ static void vficon_cell_data_cb(GtkTreeViewColumn *, GtkCellRenderer *cell,
                gchar *name_sidecars = nullptr;
                GdkRGBA color_bg;
                GdkRGBA color_fg;
-               GdkRGBA color_bg_style;
-               GdkRGBA color_fg_style;
                GtkStateType state = GTK_STATE_NORMAL;
                GtkStyle *style;
 
@@ -2158,11 +2156,8 @@ static void vficon_cell_data_cb(GtkTreeViewColumn *, GtkCellRenderer *cell,
                        state = GTK_STATE_SELECTED;
                        }
 
-               convert_gdkcolor_to_gdkrgba(&style->text[state], &color_fg_style);
-               convert_gdkcolor_to_gdkrgba(&style->base[state], &color_bg_style);
-
-               memcpy(&color_fg, &color_fg_style, sizeof(color_fg));
-               memcpy(&color_bg, &color_bg_style, sizeof(color_bg));
+               convert_gdkcolor_to_gdkrgba(&style->text[state], &color_fg);
+               convert_gdkcolor_to_gdkrgba(&style->base[state], &color_bg);
 
                if (fd->selected & SELECTION_PRELIGHT)
                        {
index bcd1145..b802a3b 100644 (file)
@@ -1964,7 +1964,6 @@ static void cell_renderer_height_override(GtkCellRenderer *renderer)
 static GdkRGBA *vflist_listview_color_shifted(GtkWidget *widget)
 {
        static GdkRGBA color;
-       static GdkRGBA color_style;
        static GtkWidget *done = nullptr;
 
        if (done != widget)
@@ -1972,9 +1971,8 @@ static GdkRGBA *vflist_listview_color_shifted(GtkWidget *widget)
                GtkStyle *style;
 
                style = gtk_widget_get_style(widget);
-               convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_NORMAL], &color_style);
+               convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_NORMAL], &color);
 
-               memcpy(&color, &color_style, sizeof(color));
                shift_color(&color, -1, 0);
                done = widget;
                }