[cache] Merge functions.

* src/cache/ftccache.c (FTC_Cache_Init): Merge into...
(ftc_cache_done): ... this function, with unnecessary checks removed.
This commit is contained in:
Alexei Podtelezhnikov 2023-05-12 22:27:08 -04:00
parent 771ff8bd03
commit e1a4e081aa
1 changed files with 17 additions and 30 deletions

47
src/cache/ftccache.c vendored
View File

@ -318,13 +318,6 @@
/*************************************************************************/ /*************************************************************************/
FT_LOCAL_DEF( FT_Error )
FTC_Cache_Init( FTC_Cache cache )
{
return ftc_cache_init( cache );
}
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
ftc_cache_init( FTC_Cache cache ) ftc_cache_init( FTC_Cache cache )
{ {
@ -341,10 +334,20 @@
} }
static void FT_LOCAL_DEF( FT_Error )
FTC_Cache_Clear( FTC_Cache cache ) FTC_Cache_Init( FTC_Cache cache )
{ {
if ( cache && cache->buckets ) return ftc_cache_init( cache );
}
FT_LOCAL_DEF( void )
ftc_cache_done( FTC_Cache cache )
{
FT_Memory memory = cache->memory;
if ( cache->buckets )
{ {
FTC_Manager manager = cache->manager; FTC_Manager manager = cache->manager;
FT_UFast count = cache->p; FT_UFast count = cache->p;
@ -370,30 +373,14 @@
cache->clazz.node_free( node, cache ); cache->clazz.node_free( node, cache );
node = next; node = next;
} }
cache->buckets[i] = NULL;
} }
ftc_cache_resize( cache );
} }
}
FT_FREE( cache->buckets );
FT_LOCAL_DEF( void ) cache->p = 0;
ftc_cache_done( FTC_Cache cache ) cache->mask = 0;
{ cache->slack = 0;
if ( cache->memory )
{
FT_Memory memory = cache->memory;
FTC_Cache_Clear( cache );
FT_FREE( cache->buckets );
cache->mask = 0;
cache->p = 0;
cache->slack = 0;
cache->memory = NULL;
}
} }