Skip to content

Commit

Permalink
cache: avoid an unnecessary cache entry lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Jan 22, 2025
1 parent 411f7a0 commit a029425
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions libvips/iofuncs/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,8 @@ vips_object_ref_arg(VipsObject *object,
}

static void
vips_operation_touch(VipsOperation *operation)
vips_entry_touch(VipsOperationCacheEntry *entry)
{
VipsOperationCacheEntry *entry = vips_cache_operation_get(operation);

vips_cache_time += 1;

/* Don't up the time for invalid items -- we want them to fall out of
Expand All @@ -629,21 +627,21 @@ vips_operation_touch(VipsOperation *operation)
entry->time = vips_cache_time;
}

/* Ref an operation for the cache. The operation itself, plus all the output
/* Ref a cache entry. The operation itself, plus all the output
* objects it makes.
*/
static void
vips_cache_ref(VipsOperation *operation)
vips_entry_ref(VipsOperationCacheEntry *entry)
{
#ifdef DEBUG
printf("vips_cache_ref: ");
vips_object_print_summary(VIPS_OBJECT(operation));
vips_object_print_summary(VIPS_OBJECT(entry->operation));
#endif /*DEBUG*/

g_object_ref(operation);
(void) vips_argument_map(VIPS_OBJECT(operation),
g_object_ref(entry->operation);
(void) vips_argument_map(VIPS_OBJECT(entry->operation),
vips_object_ref_arg, NULL, NULL);
vips_operation_touch(operation);
vips_entry_touch(entry);
}

static void
Expand Down Expand Up @@ -674,7 +672,7 @@ vips_cache_insert(VipsOperation *operation)
entry->invalid = FALSE;

g_hash_table_insert(vips_cache_table, operation, entry);
vips_cache_ref(operation);
vips_entry_ref(entry);

/* If the operation signals "invalidate", we must tag this cache entry
* for removal.
Expand Down Expand Up @@ -822,7 +820,7 @@ vips_cache_operation_buildp(VipsOperation **operation)
* passed.
*/
if (hit) {
vips_cache_ref(hit->operation);
vips_entry_ref(hit);
g_object_unref(*operation);
*operation = hit->operation;

Expand Down

0 comments on commit a029425

Please sign in to comment.