Commit 03752a92 authored by Elliot Lee's avatar Elliot Lee
Browse files

misc minor performance improvements

parent 401e04f4
...@@ -176,7 +176,6 @@ gimp_SOURCES = \ ...@@ -176,7 +176,6 @@ gimp_SOURCES = \
layers_dialogP.h \ layers_dialogP.h \
levels.c \ levels.c \
levels.h \ levels.h \
linked.c \
linked.h \ linked.h \
magnify.c \ magnify.c \
magnify.h \ magnify.h \
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <math.h> #include <math.h>
#include <string.h>
#include "appenv.h" #include "appenv.h"
#include "asupsample.h" #include "asupsample.h"
...@@ -114,17 +115,8 @@ adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_depth, double ...@@ -114,17 +115,8 @@ adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_depth, double
block = g_malloc((sub_pixel_size + 1) * sizeof(sample_t *)); /* Rows */ block = g_malloc((sub_pixel_size + 1) * sizeof(sample_t *)); /* Rows */
for (y = 0; y < (sub_pixel_size + 1); y++) for (y = 0; y < (sub_pixel_size + 1); y++)
block[y] = g_malloc((sub_pixel_size + 1) * sizeof(sample_t)); /* Columns */ /* Columns */
block[y] = g_malloc0((sub_pixel_size + 1) * sizeof(sample_t));
for (y = 0; y < (sub_pixel_size + 1); y++)
for (x = 0; x < (sub_pixel_size + 1); x++) {
block[y][x].ready = 0;
block[y][x].color.r = 0.0;
block[y][x].color.g = 0.0;
block[y][x].color.b = 0.0;
block[y][x].color.a = 0.0;
} /* for */
/* Render region */ /* Render region */
...@@ -152,10 +144,9 @@ adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_depth, double ...@@ -152,10 +144,9 @@ adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_depth, double
/* Copy samples from top row to block */ /* Copy samples from top row to block */
for (xtt = 0, xt = (x - x1) * sub_pixel_size; memcpy(block[0],
xtt < (sub_pixel_size + 1); top_row + ((x - x1) * sub_pixel_size),
xtt++, xt++) sizeof(sample_t) * sub_pixel_size);
block[0][xtt] = top_row[xt];
/* Render pixel on (x, y) */ /* Render pixel on (x, y) */
...@@ -171,10 +162,9 @@ adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_depth, double ...@@ -171,10 +162,9 @@ adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_depth, double
top_row[((x - x1) + 1) * sub_pixel_size] = block[0][sub_pixel_size]; top_row[((x - x1) + 1) * sub_pixel_size] = block[0][sub_pixel_size];
for (xtt = 0, xt = (x - x1) * sub_pixel_size; memcpy(bot_row + ((x - x1) * sub_pixel_size),
xtt < (sub_pixel_size + 1); block[sub_pixel_size],
xtt++, xt++) sub_pixel_size * sizeof(sample_t));
bot_row[xt] = block[sub_pixel_size][xtt];
/* Swap first and last columns */ /* Swap first and last columns */
......
...@@ -784,7 +784,8 @@ layers_dialog_update (int gimage_id) ...@@ -784,7 +784,8 @@ layers_dialog_update (int gimage_id)
list = next_item(list); list = next_item(list);
layer_widget_delete (lw); layer_widget_delete (lw);
} }
layersD->layer_widgets = free_list (layersD->layer_widgets); free_list (layersD->layer_widgets);
layersD->layer_widgets = NULL;
if (! (gimage = gimage_get_ID (layersD->gimage_id))) if (! (gimage = gimage_get_ID (layersD->gimage_id)))
return; return;
......
...@@ -784,7 +784,8 @@ layers_dialog_update (int gimage_id) ...@@ -784,7 +784,8 @@ layers_dialog_update (int gimage_id)
list = next_item(list); list = next_item(list);
layer_widget_delete (lw); layer_widget_delete (lw);
} }
layersD->layer_widgets = free_list (layersD->layer_widgets); free_list (layersD->layer_widgets);
layersD->layer_widgets = NULL;
if (! (gimage = gimage_get_ID (layersD->gimage_id))) if (! (gimage = gimage_get_ID (layersD->gimage_id)))
return; return;
......
...@@ -15,23 +15,23 @@ ...@@ -15,23 +15,23 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* This is compatibility stuff only... */
#ifndef __LINKED_H__ #ifndef __LINKED_H__
#define __LINKED_H__ #define __LINKED_H__
typedef struct _link #include <glib.h>
{
void *data; typedef GSList * link_ptr;
struct _link *next;
} *link_ptr;
extern link_ptr alloc_list (void); #define alloc_list() g_slist_alloc()
extern link_ptr free_list (link_ptr); #define free_list(x) g_slist_free((x))
extern link_ptr add_to_list (link_ptr, void *); #define add_to_list(x, y) g_slist_prepend((x), (y))
extern link_ptr append_to_list (link_ptr, void *); #define append_to_list(x, y) g_slist_append((x), (y))
extern link_ptr insert_in_list (link_ptr, void *, int); #define insert_in_list(x, y, z) g_slist_insert((x), (y), (z))
extern link_ptr remove_from_list (link_ptr, void *); #define remove_from_list(x, y) g_slist_remove((x), (y))
extern link_ptr next_item (link_ptr); #define next_item(x) (x)?g_slist_next((x)):NULL
extern link_ptr nth_item (link_ptr, int); #define nth_item(x, y) g_slist_nth((x), (y))
extern int list_length (link_ptr); #define list_length(x) g_slist_length((x))
#endif #endif
...@@ -1740,8 +1740,7 @@ combine_inten_a_and_channel_mask_pixels (unsigned char *src, ...@@ -1740,8 +1740,7 @@ combine_inten_a_and_channel_mask_pixels (unsigned char *src,
dest[b] = new_alpha; dest[b] = new_alpha;
} }
else else
for (b = 0; b < bytes; b++) memcpy(dest, src, bytes);
dest[b] = src[b];
/* advance pointers */ /* advance pointers */
src+=bytes; src+=bytes;
...@@ -1784,8 +1783,7 @@ combine_inten_a_and_channel_selection_pixels (unsigned char *src, ...@@ -1784,8 +1783,7 @@ combine_inten_a_and_channel_selection_pixels (unsigned char *src,
dest[b] = new_alpha; dest[b] = new_alpha;
} }
else else
for (b = 0; b < bytes; b++) memcpy(dest, src, bytes);
dest[b] = src[b];
/* advance pointers */ /* advance pointers */
src+=bytes; src+=bytes;
...@@ -3353,6 +3351,7 @@ shapeburst_region (PixelRegion *srcPR, ...@@ -3353,6 +3351,7 @@ shapeburst_region (PixelRegion *srcPR,
float *distp_prev; float *distp_prev;
float *tmp; float *tmp;
float min_prev; float min_prev;
float float_tmp;
int min; int min;
int min_left; int min_left;
int length; int length;
...@@ -3380,8 +3379,7 @@ shapeburst_region (PixelRegion *srcPR, ...@@ -3380,8 +3379,7 @@ shapeburst_region (PixelRegion *srcPR,
for (i = 0; i < srcPR->h; i++) for (i = 0; i < srcPR->h; i++)
{ {
/* set the current dist row to 0's */ /* set the current dist row to 0's */
for (j = 0; j < length; j++) memset(distp_cur - 1, 0, sizeof(float) * (length - 1));
distp_cur[j - 1] = 0.0;
for (j = 0; j < srcPR->w; j++) for (j = 0; j < srcPR->w; j++)
{ {
...@@ -3442,10 +3440,10 @@ shapeburst_region (PixelRegion *srcPR, ...@@ -3442,10 +3440,10 @@ shapeburst_region (PixelRegion *srcPR,
min++; min++;
} }
distp_cur[j] = min + fraction / 256.0; float_tmp = distp_cur[j] = min + fraction / 256.0;
if (distp_cur[j] > max_iterations) if (float_tmp > max_iterations)
max_iterations = distp_cur[j]; max_iterations = float_tmp;
} }
/* set the dist row */ /* set the dist row */
......
...@@ -1740,8 +1740,7 @@ combine_inten_a_and_channel_mask_pixels (unsigned char *src, ...@@ -1740,8 +1740,7 @@ combine_inten_a_and_channel_mask_pixels (unsigned char *src,
dest[b] = new_alpha; dest[b] = new_alpha;
} }
else else
for (b = 0; b < bytes; b++) memcpy(dest, src, bytes);
dest[b] = src[b];
/* advance pointers */ /* advance pointers */
src+=bytes; src+=bytes;
...@@ -1784,8 +1783,7 @@ combine_inten_a_and_channel_selection_pixels (unsigned char *src, ...@@ -1784,8 +1783,7 @@ combine_inten_a_and_channel_selection_pixels (unsigned char *src,
dest[b] = new_alpha; dest[b] = new_alpha;
} }
else else
for (b = 0; b < bytes; b++) memcpy(dest, src, bytes);
dest[b] = src[b];
/* advance pointers */ /* advance pointers */
src+=bytes; src+=bytes;
...@@ -3353,6 +3351,7 @@ shapeburst_region (PixelRegion *srcPR, ...@@ -3353,6 +3351,7 @@ shapeburst_region (PixelRegion *srcPR,
float *distp_prev; float *distp_prev;
float *tmp; float *tmp;
float min_prev; float min_prev;
float float_tmp;
int min; int min;
int min_left; int min_left;
int length; int length;
...@@ -3380,8 +3379,7 @@ shapeburst_region (PixelRegion *srcPR, ...@@ -3380,8 +3379,7 @@ shapeburst_region (PixelRegion *srcPR,
for (i = 0; i < srcPR->h; i++) for (i = 0; i < srcPR->h; i++)
{ {
/* set the current dist row to 0's */ /* set the current dist row to 0's */
for (j = 0; j < length; j++) memset(distp_cur - 1, 0, sizeof(float) * (length - 1));
distp_cur[j - 1] = 0.0;
for (j = 0; j < srcPR->w; j++) for (j = 0; j < srcPR->w; j++)
{ {
...@@ -3442,10 +3440,10 @@ shapeburst_region (PixelRegion *srcPR, ...@@ -3442,10 +3440,10 @@ shapeburst_region (PixelRegion *srcPR,
min++; min++;
} }
distp_cur[j] = min + fraction / 256.0; float_tmp = distp_cur[j] = min + fraction / 256.0;
if (distp_cur[j] > max_iterations) if (float_tmp > max_iterations)
max_iterations = distp_cur[j]; max_iterations = float_tmp;
} }
/* set the dist row */ /* set the dist row */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment