misc minor performance improvements

This commit is contained in:
Elliot Lee 1998-01-20 04:51:56 +00:00
parent 401e04f469
commit 03752a9264
7 changed files with 42 additions and 55 deletions

View File

@ -176,7 +176,6 @@ gimp_SOURCES = \
layers_dialogP.h \
levels.c \
levels.h \
linked.c \
linked.h \
magnify.c \
magnify.h \

View File

@ -30,6 +30,7 @@
#include <math.h>
#include <string.h>
#include "appenv.h"
#include "asupsample.h"
@ -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 */
for (y = 0; y < (sub_pixel_size + 1); y++)
block[y] = g_malloc((sub_pixel_size + 1) * sizeof(sample_t)); /* Columns */
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 */
/* Columns */
block[y] = g_malloc0((sub_pixel_size + 1) * sizeof(sample_t));
/* Render region */
@ -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 */
for (xtt = 0, xt = (x - x1) * sub_pixel_size;
xtt < (sub_pixel_size + 1);
xtt++, xt++)
block[0][xtt] = top_row[xt];
memcpy(block[0],
top_row + ((x - x1) * sub_pixel_size),
sizeof(sample_t) * sub_pixel_size);
/* Render pixel on (x, y) */
@ -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];
for (xtt = 0, xt = (x - x1) * sub_pixel_size;
xtt < (sub_pixel_size + 1);
xtt++, xt++)
bot_row[xt] = block[sub_pixel_size][xtt];
memcpy(bot_row + ((x - x1) * sub_pixel_size),
block[sub_pixel_size],
sub_pixel_size * sizeof(sample_t));
/* Swap first and last columns */
@ -226,7 +216,7 @@ render_sub_pixel(int max_depth, int depth, sample_t **block,
/* Get offsets for corners */
dx1 = (double) (x1 - sub_pixel_size / 2) / sub_pixel_size;
dx1 = (double) (x1 - sub_pixel_size / 2) / sub_pixel_size;
dx3 = (double) (x3 - sub_pixel_size / 2) / sub_pixel_size;
dy1 = (double) (y1 - sub_pixel_size / 2) / sub_pixel_size;

View File

@ -784,7 +784,8 @@ layers_dialog_update (int gimage_id)
list = next_item(list);
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)))
return;

View File

@ -784,7 +784,8 @@ layers_dialog_update (int gimage_id)
list = next_item(list);
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)))
return;

View File

@ -15,23 +15,23 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* This is compatibility stuff only... */
#ifndef __LINKED_H__
#define __LINKED_H__
typedef struct _link
{
void *data;
struct _link *next;
} *link_ptr;
#include <glib.h>
extern link_ptr alloc_list (void);
extern link_ptr free_list (link_ptr);
extern link_ptr add_to_list (link_ptr, void *);
extern link_ptr append_to_list (link_ptr, void *);
extern link_ptr insert_in_list (link_ptr, void *, int);
extern link_ptr remove_from_list (link_ptr, void *);
extern link_ptr next_item (link_ptr);
extern link_ptr nth_item (link_ptr, int);
extern int list_length (link_ptr);
typedef GSList * link_ptr;
#define alloc_list() g_slist_alloc()
#define free_list(x) g_slist_free((x))
#define add_to_list(x, y) g_slist_prepend((x), (y))
#define append_to_list(x, y) g_slist_append((x), (y))
#define insert_in_list(x, y, z) g_slist_insert((x), (y), (z))
#define remove_from_list(x, y) g_slist_remove((x), (y))
#define next_item(x) (x)?g_slist_next((x)):NULL
#define nth_item(x, y) g_slist_nth((x), (y))
#define list_length(x) g_slist_length((x))
#endif

View File

@ -1740,8 +1740,7 @@ combine_inten_a_and_channel_mask_pixels (unsigned char *src,
dest[b] = new_alpha;
}
else
for (b = 0; b < bytes; b++)
dest[b] = src[b];
memcpy(dest, src, bytes);
/* advance pointers */
src+=bytes;
@ -1784,8 +1783,7 @@ combine_inten_a_and_channel_selection_pixels (unsigned char *src,
dest[b] = new_alpha;
}
else
for (b = 0; b < bytes; b++)
dest[b] = src[b];
memcpy(dest, src, bytes);
/* advance pointers */
src+=bytes;
@ -3353,6 +3351,7 @@ shapeburst_region (PixelRegion *srcPR,
float *distp_prev;
float *tmp;
float min_prev;
float float_tmp;
int min;
int min_left;
int length;
@ -3380,8 +3379,7 @@ shapeburst_region (PixelRegion *srcPR,
for (i = 0; i < srcPR->h; i++)
{
/* set the current dist row to 0's */
for (j = 0; j < length; j++)
distp_cur[j - 1] = 0.0;
memset(distp_cur - 1, 0, sizeof(float) * (length - 1));
for (j = 0; j < srcPR->w; j++)
{
@ -3442,10 +3440,10 @@ shapeburst_region (PixelRegion *srcPR,
min++;
}
distp_cur[j] = min + fraction / 256.0;
float_tmp = distp_cur[j] = min + fraction / 256.0;
if (distp_cur[j] > max_iterations)
max_iterations = distp_cur[j];
if (float_tmp > max_iterations)
max_iterations = float_tmp;
}
/* set the dist row */

View File

@ -1740,8 +1740,7 @@ combine_inten_a_and_channel_mask_pixels (unsigned char *src,
dest[b] = new_alpha;
}
else
for (b = 0; b < bytes; b++)
dest[b] = src[b];
memcpy(dest, src, bytes);
/* advance pointers */
src+=bytes;
@ -1784,8 +1783,7 @@ combine_inten_a_and_channel_selection_pixels (unsigned char *src,
dest[b] = new_alpha;
}
else
for (b = 0; b < bytes; b++)
dest[b] = src[b];
memcpy(dest, src, bytes);
/* advance pointers */
src+=bytes;
@ -3353,6 +3351,7 @@ shapeburst_region (PixelRegion *srcPR,
float *distp_prev;
float *tmp;
float min_prev;
float float_tmp;
int min;
int min_left;
int length;
@ -3380,8 +3379,7 @@ shapeburst_region (PixelRegion *srcPR,
for (i = 0; i < srcPR->h; i++)
{
/* set the current dist row to 0's */
for (j = 0; j < length; j++)
distp_cur[j - 1] = 0.0;
memset(distp_cur - 1, 0, sizeof(float) * (length - 1));
for (j = 0; j < srcPR->w; j++)
{
@ -3442,10 +3440,10 @@ shapeburst_region (PixelRegion *srcPR,
min++;
}
distp_cur[j] = min + fraction / 256.0;
float_tmp = distp_cur[j] = min + fraction / 256.0;
if (distp_cur[j] > max_iterations)
max_iterations = distp_cur[j];
if (float_tmp > max_iterations)
max_iterations = float_tmp;
}
/* set the dist row */