tiny cleanups

This commit is contained in:
John Cupitt 2017-09-15 10:39:06 +01:00
parent f4eb1fcf80
commit 3d40769401
2 changed files with 18 additions and 8 deletions

View File

@ -445,16 +445,22 @@ vips_operation_equal( VipsOperation *a, VipsOperation *b )
return( FALSE );
}
void *
vips__cache_once_init( void )
{
vips_cache_lock = vips_g_mutex_new();
vips_cache_table = g_hash_table_new(
(GHashFunc) vips_operation_hash,
(GEqualFunc) vips_operation_equal );
}
void
vips__cache_init( void )
{
if( !vips_cache_table ) {
vips_cache_lock = vips_g_mutex_new();
static GOnce once = G_ONCE_INIT;
vips_cache_table = g_hash_table_new(
(GHashFunc) vips_operation_hash,
(GEqualFunc) vips_operation_equal );
}
g_once( &once, (GThreadFunc) vips__cache_once_init, NULL );
}
static void *

View File

@ -281,8 +281,7 @@ vips_thumbnail_open( VipsThumbnail *thumbnail )
}
else if( vips_isprefix( "VipsForeignLoadPdf", thumbnail->loader ) ||
vips_isprefix( "VipsForeignLoadSvg", thumbnail->loader ) ) {
scale = 1.0 /
vips_thumbnail_calculate_common_shrink( thumbnail,
scale = 1.0 / vips_thumbnail_calculate_common_shrink( thumbnail,
thumbnail->input_width, thumbnail->input_height );
g_info( "loading PDF/SVG with factor %g pre-scale", scale );
@ -698,6 +697,11 @@ vips_thumbnail_file_open( VipsThumbnail *thumbnail, int shrink, double scale )
{
VipsThumbnailFile *file = (VipsThumbnailFile *) thumbnail;
/* If both shrink and scale have been set, something is wrong. It
* should be one or the other (or neither).
*/
g_assert( shrink == 1 || scale == 1.0 );
if( shrink != 1 )
return( vips_image_new_from_file( file->filename,
"access", VIPS_ACCESS_SEQUENTIAL,