projects
/
geeqie.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2a3aaf4
)
Use std::swap instead of temporary values
author
Arkadiy Illarionov
<qarkai@gmail.com>
Sun, 10 Mar 2024 11:57:45 +0000
(14:57 +0300)
committer
Colin Clark
<colin.clark@cclark.uk>
Sun, 10 Mar 2024 14:44:38 +0000
(14:44 +0000)
src/collect-table.cc
patch
|
blob
|
history
src/collect.cc
patch
|
blob
|
history
src/filedata.cc
patch
|
blob
|
history
src/layout.cc
patch
|
blob
|
history
src/pixbuf-util.cc
patch
|
blob
|
history
src/renderer-tiles.cc
patch
|
blob
|
history
src/slideshow.cc
patch
|
blob
|
history
src/view-file/view-file-icon.cc
patch
|
blob
|
history
diff --git
a/src/collect-table.cc
b/src/collect-table.cc
index
874d15d
..
0d3016f
100644
(file)
--- a/
src/collect-table.cc
+++ b/
src/collect-table.cc
@@
-22,6
+22,7
@@
#include "collect-table.h"
#include <cstddef>
#include "collect-table.h"
#include <cstddef>
+#include <utility>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@
-511,7
+512,6
@@
static void collection_table_select_region_util(CollectTable *ct, CollectInfo *s
gint col1;
gint row2;
gint col2;
gint col1;
gint row2;
gint col2;
- gint t;
gint i;
gint j;
gint i;
gint j;
@@
-548,15
+548,11
@@
static void collection_table_select_region_util(CollectTable *ct, CollectInfo *s
if (row2 < row1)
{
if (row2 < row1)
{
- t = row1;
- row1 = row2;
- row2 = t;
+ std::swap(row1, row2);
}
if (col2 < col1)
{
}
if (col2 < col1)
{
- t = col1;
- col1 = col2;
- col2 = t;
+ std::swap(col1, col2);
}
DEBUG_1("table: %d x %d to %d x %d", row1, col1, row2, col2);
}
DEBUG_1("table: %d x %d to %d x %d", row1, col1, row2, col2);
diff --git
a/src/collect.cc
b/src/collect.cc
index
2f7ca47
..
5b9a62f
100644
(file)
--- a/
src/collect.cc
+++ b/
src/collect.cc
@@
-26,6
+26,7
@@
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <ctime>
+#include <utility>
#include <glib-object.h>
#include <glib-object.h>
@@
-214,7
+215,6
@@
GList *collection_list_randomize(GList *list)
guint random;
guint length;
guint i;
guint random;
guint length;
guint i;
- gpointer tmp;
GList *nlist;
GList *olist;
GList *nlist;
GList *olist;
@@
-228,9
+228,7
@@
GList *collection_list_randomize(GList *list)
random = static_cast<guint>(1.0 * length * rand()/(RAND_MAX + 1.0));
olist = g_list_nth(list, i);
nlist = g_list_nth(list, random);
random = static_cast<guint>(1.0 * length * rand()/(RAND_MAX + 1.0));
olist = g_list_nth(list, i);
nlist = g_list_nth(list, random);
- tmp = olist->data;
- olist->data = nlist->data;
- nlist->data = tmp;
+ std::swap(olist->data, nlist->data);
}
return list;
}
return list;
diff --git
a/src/filedata.cc
b/src/filedata.cc
index
d66e80b
..
c0a04ab
100644
(file)
--- a/
src/filedata.cc
+++ b/
src/filedata.cc
@@
-30,6
+30,7
@@
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <ctime>
+#include <utility>
#include <glib-object.h>
#include <grp.h>
#include <glib-object.h>
#include <grp.h>
@@
-1171,9
+1172,7
@@
gint filelist_sort_compare_filedata(FileData *fa, FileData *fb)
gint ret;
if (!filelist_sort_ascend)
{
gint ret;
if (!filelist_sort_ascend)
{
- FileData *tmp = fa;
- fa = fb;
- fb = tmp;
+ std::swap(fa, fb);
}
switch (filelist_sort_method)
}
switch (filelist_sort_method)
diff --git
a/src/layout.cc
b/src/layout.cc
index
c478a79
..
f955399
100644
(file)
--- a/
src/layout.cc
+++ b/
src/layout.cc
@@
-24,6
+24,7
@@
#include <unistd.h>
#include <cstring>
#include <unistd.h>
#include <cstring>
+#include <utility>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
@@
-1915,11
+1916,7
@@
static void layout_grid_setup(LayoutWindow *lw)
if (!layout_location_vertical(static_cast<LayoutLocation>(priority_location)))
{
if (!layout_location_vertical(static_cast<LayoutLocation>(priority_location)))
{
- GtkWidget *tmp;
-
- tmp = v;
- v = h;
- h = tmp;
+ std::swap(v, h);
}
gq_gtk_box_pack_start(GTK_BOX(lw->group_box), v, TRUE, TRUE, 0);
}
gq_gtk_box_pack_start(GTK_BOX(lw->group_box), v, TRUE, TRUE, 0);
diff --git
a/src/pixbuf-util.cc
b/src/pixbuf-util.cc
index
35abc2f
..
0d87b7f
100644
(file)
--- a/
src/pixbuf-util.cc
+++ b/
src/pixbuf-util.cc
@@
-25,6
+25,7
@@
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstring>
+#include <utility>
#include <cairo.h>
#include <gio/gio.h>
#include <cairo.h>
#include <gio/gio.h>
@@
-1044,7
+1045,6
@@
void pixbuf_draw_triangle(GdkPixbuf *pb,
gint slope1_x;
gint slope1_y;
gint y;
gint slope1_x;
gint slope1_y;
gint y;
- gint t;
gboolean middle = FALSE;
if (!pb) return;
gboolean middle = FALSE;
if (!pb) return;
@@
-1073,18
+1073,18
@@
void pixbuf_draw_triangle(GdkPixbuf *pb,
if (y1 > y2)
{
if (y1 > y2)
{
-
t = x1; x1 = x2; x2 = t
;
-
t = y1; y1 = y2; y2 = t
;
+
std::swap(x1, x2)
;
+
std::swap(y1, y2)
;
}
if (y2 > y3)
{
}
if (y2 > y3)
{
-
t = x2; x2 = x3; x3 = t
;
-
t = y2; y2 = y3; y3 = t
;
+
std::swap(x2, x3)
;
+
std::swap(y2, y3)
;
}
if (y1 > y2)
{
}
if (y1 > y2)
{
-
t = x1; x1 = x2; x2 = t
;
-
t = y1; y1 = y2; y2 = t
;
+
std::swap(x1, x2)
;
+
std::swap(y1, y2)
;
}
slope1 = static_cast<gdouble>(y2 - y1);
}
slope1 = static_cast<gdouble>(y2 - y1);
@@
-1114,7
+1114,7
@@
void pixbuf_draw_triangle(GdkPixbuf *pb,
if (xa > xb)
{
if (xa > xb)
{
-
t = xa; xa = xb; xb = t
;
+
std::swap(xa, xb)
;
}
xa = CLAMP(xa, fx1, fx2);
}
xa = CLAMP(xa, fx1, fx2);
@@
-1149,10
+1149,8
@@
static gboolean util_clip_line(gdouble clip_x, gdouble clip_y, gdouble clip_w, g
if (x1 > x2)
{
if (x1 > x2)
{
- gdouble t;
-
- t = x1; x1 = x2; x2 = t;
- t = y1; y1 = y2; y2 = t;
+ std::swap(x1, x2);
+ std::swap(y1, y2);
flip = TRUE;
}
flip = TRUE;
}
@@
-1191,12
+1189,10
@@
static gboolean util_clip_line(gdouble clip_x, gdouble clip_y, gdouble clip_w, g
}
else
{
}
else
{
- gdouble t;
-
if (y1 < clip_y || y2 > clip_y + clip_h) return FALSE;
if (y1 < clip_y || y2 > clip_y + clip_h) return FALSE;
-
t = x1; x1 = x2; x2 = t
;
-
t = y1; y1 = y2; y2 = t
;
+
std::swap(x1, x2)
;
+
std::swap(y1, y2)
;
flip = !flip;
}
flip = !flip;
}
@@
-1293,9
+1289,8
@@
void pixbuf_draw_line(GdkPixbuf *pb,
{
if (rx1 > rx2)
{
{
if (rx1 > rx2)
{
- gdouble t;
- t = rx1; rx1 = rx2; rx2 = t;
- t = ry1; ry1 = ry2; ry2 = t;
+ std::swap(rx1, rx2);
+ std::swap(ry1, ry2);
}
slope = rx2 - rx1;
}
slope = rx2 - rx1;
@@
-1320,9
+1315,8
@@
void pixbuf_draw_line(GdkPixbuf *pb,
{
if (ry1 > ry2)
{
{
if (ry1 > ry2)
{
- gdouble t;
- t = rx1; rx1 = rx2; rx2 = t;
- t = ry1; ry1 = ry2; ry2 = t;
+ std::swap(rx1, rx2);
+ std::swap(ry1, ry2);
}
slope = ry2 - ry1;
}
slope = ry2 - ry1;
diff --git
a/src/renderer-tiles.cc
b/src/renderer-tiles.cc
index
bb85977
..
5e3068c
100644
(file)
--- a/
src/renderer-tiles.cc
+++ b/
src/renderer-tiles.cc
@@
-24,6
+24,7
@@
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstring>
+#include <utility>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@
-1512,14
+1513,11
@@
static void rt_tile_render(RendererTiles *rt, ImageTile *it,
switch (orientation)
{
switch (orientation)
{
- gdouble tmp;
case EXIF_ORIENTATION_LEFT_TOP:
case EXIF_ORIENTATION_RIGHT_TOP:
case EXIF_ORIENTATION_RIGHT_BOTTOM:
case EXIF_ORIENTATION_LEFT_BOTTOM:
case EXIF_ORIENTATION_LEFT_TOP:
case EXIF_ORIENTATION_RIGHT_TOP:
case EXIF_ORIENTATION_RIGHT_BOTTOM:
case EXIF_ORIENTATION_LEFT_BOTTOM:
- tmp = scale_x;
- scale_x = scale_y;
- scale_y = tmp;
+ std::swap(scale_x, scale_y);
break;
default:
/* nothing to do */
break;
default:
/* nothing to do */
diff --git
a/src/slideshow.cc
b/src/slideshow.cc
index
65e48f1
..
56934be
100644
(file)
--- a/
src/slideshow.cc
+++ b/
src/slideshow.cc
@@
-22,6
+22,7
@@
#include "slideshow.h"
#include <cstdlib>
#include "slideshow.h"
#include <cstdlib>
+#include <utility>
#include "collect.h"
#include "filedata.h"
#include "collect.h"
#include "filedata.h"
@@
-93,21
+94,13
@@
static GPtrArray *generate_ptr_array_from_list(GList *src_list)
return arr;
}
return arr;
}
-static void swap(GPtrArray *array, guint index1, guint index2)
-{
- gpointer temp = g_ptr_array_index(array, index1);
-
- g_ptr_array_index(array, index1) = g_ptr_array_index(array, index2);
- g_ptr_array_index(array, index2) = temp;
-}
-
static void ptr_array_random_shuffle(GPtrArray *array)
{
guint i;
for (i = 0; i < array->len; ++i)
{
guint p = static_cast<double>(rand()) / (static_cast<double>(RAND_MAX) + 1.0) * array->len;
static void ptr_array_random_shuffle(GPtrArray *array)
{
guint i;
for (i = 0; i < array->len; ++i)
{
guint p = static_cast<double>(rand()) / (static_cast<double>(RAND_MAX) + 1.0) * array->len;
- s
wap(array, i, p
);
+ s
td::swap(g_ptr_array_index(array, i), g_ptr_array_index(array, p)
);
}
}
}
}
diff --git
a/src/view-file/view-file-icon.cc
b/src/view-file/view-file-icon.cc
index
1a61eac
..
fe7c180
100644
(file)
--- a/
src/view-file/view-file-icon.cc
+++ b/
src/view-file/view-file-icon.cc
@@
-22,6
+22,7
@@
#include "view-file-icon.h"
#include <cstring>
#include "view-file-icon.h"
#include <cstring>
+#include <utility>
#include <glib-object.h>
#include <glib-object.h>
@@
-772,7
+773,6
@@
static void vficon_select_region_util(ViewFile *vf, FileData *start, FileData *e
gint col1;
gint row2;
gint col2;
gint col1;
gint row2;
gint col2;
- gint t;
gint i;
gint j;
gint i;
gint j;
@@
-787,9
+787,7
@@
static void vficon_select_region_util(ViewFile *vf, FileData *start, FileData *e
if (g_list_index(vf->list, start) > g_list_index(vf->list, end))
{
if (g_list_index(vf->list, start) > g_list_index(vf->list, end))
{
- FileData *tmp = start;
- start = end;
- end = tmp;
+ std::swap(start, end);
}
work = g_list_find(vf->list, start);
}
work = g_list_find(vf->list, start);
@@
-809,15
+807,11
@@
static void vficon_select_region_util(ViewFile *vf, FileData *start, FileData *e
// rectangular_selection==true.
if (row2 < row1)
{
// rectangular_selection==true.
if (row2 < row1)
{
- t = row1;
- row1 = row2;
- row2 = t;
+ std::swap(row1, row2);
}
if (col2 < col1)
{
}
if (col2 < col1)
{
- t = col1;
- col1 = col2;
- col2 = t;
+ std::swap(col1, col2);
}
DEBUG_1("table: %d x %d to %d x %d", row1, col1, row2, col2);
}
DEBUG_1("table: %d x %d to %d x %d", row1, col1, row2, col2);