only enable sanity checks in debug mode

We had a couple of sanity checks always on. As a result, libvips could
get slow for large pipelines.

Move them into g_assert().
This commit is contained in:
John Cupitt 2019-03-01 13:01:08 +00:00
parent b565f2fc68
commit 33d90b5e26
4 changed files with 9 additions and 18 deletions

View File

@ -1158,9 +1158,7 @@ strip_work( VipsThreadState *state, void *a )
}
}
#ifdef DEBUG
vips_object_sanity( VIPS_OBJECT( strip->image ) );
#endif /*DEBUG*/
g_assert( vips_object_sanity( VIPS_OBJECT( strip->image ) ) );
/* Extract relative to the strip top-left corner.
*/

View File

@ -2918,9 +2918,8 @@ vips_image_hasalpha( VipsImage *image )
*/
int
vips_image_write_prepare( VipsImage *image )
{
if( !vips_object_sanity( VIPS_OBJECT( image ) ) )
return( -1 );
{
g_assert( vips_object_sanity( VIPS_OBJECT( image ) ) );
if( image->Xsize <= 0 ||
image->Ysize <= 0 ||
@ -3181,8 +3180,7 @@ vips_image_wio_input( VipsImage *image )
{
VipsImage *t1;
if( !vips_object_sanity( VIPS_OBJECT( image ) ) )
return( -1 );
g_assert( vips_object_sanity( VIPS_OBJECT( image ) ) );
#ifdef DEBUG_IO
printf( "vips_image_wio_input: wio input for %s\n",
@ -3406,8 +3404,7 @@ vips_image_inplace( VipsImage *image )
int
vips_image_pio_input( VipsImage *image )
{
if( !vips_object_sanity( VIPS_OBJECT( image ) ) )
return( -1 );
g_assert( vips_object_sanity( VIPS_OBJECT( image ) ) );
#ifdef DEBUG_IO
printf( "vips_image_pio_input: enabling partial input for %s\n",

View File

@ -527,12 +527,8 @@ vips_region_new( VipsImage *image )
* We can't use the property system, we need to be very threaded.
*/
g_object_ref( image );
g_assert( G_OBJECT( image )->ref_count > 1 );
#ifdef DEBUG
g_assert( vips_object_sanity( VIPS_OBJECT( image ) ) );
#endif /*DEBUG*/
region = VIPS_REGION( g_object_new( VIPS_TYPE_REGION, NULL ) );
region->im = image;
@ -542,9 +538,7 @@ vips_region_new( VipsImage *image )
return( NULL );
}
#ifdef DEBUG
g_assert( vips_object_sanity( VIPS_OBJECT( region ) ) );
#endif /*DEBUG*/
return( region );
}

View File

@ -338,7 +338,8 @@ vips_reorder_prepare_many( VipsImage *image, VipsRegion **regions, VipsRect *r )
for( i = 0; i < reorder->n_inputs; i++ ) {
g_assert( regions[i] );
if( vips_region_prepare( regions[reorder->recomp_order[i]], r ) )
if( vips_region_prepare(
regions[reorder->recomp_order[i]], r ) )
return( -1 );
}
@ -374,7 +375,8 @@ vips_reorder_margin_hint( VipsImage *image, int margin )
void
vips__reorder_clear( VipsImage *image )
{
g_object_set_qdata( G_OBJECT( image ), vips__image_reorder_quark, NULL );
g_object_set_qdata( G_OBJECT( image ),
vips__image_reorder_quark, NULL );
}
void