Merge pull request #2484 from dbnicholson/prune-serialize

lib/prune: Avoid unnecessary object serialization
This commit is contained in:
Colin Walters 2021-11-18 14:49:15 -05:00 committed by GitHub
commit f552e30c0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 12 deletions

View File

@ -39,17 +39,17 @@ typedef struct {
} OtPruneData; } OtPruneData;
static gboolean static gboolean
maybe_prune_loose_object (OtPruneData *data, maybe_prune_loose_object (OtPruneData *data,
OstreeRepoPruneFlags flags, OstreeRepoPruneFlags flags,
const char *checksum, GVariant *key,
OstreeObjectType objtype, GCancellable *cancellable,
GCancellable *cancellable, GError **error)
GError **error)
{ {
gboolean reachable = FALSE; gboolean reachable = FALSE;
g_autoptr(GVariant) key = NULL; const char *checksum;
OstreeObjectType objtype;
key = ostree_object_name_serialize (checksum, objtype); ostree_object_name_deserialize (key, &checksum, &objtype);
if (g_hash_table_lookup_extended (data->reachable, key, NULL, NULL)) if (g_hash_table_lookup_extended (data->reachable, key, NULL, NULL))
reachable = TRUE; reachable = TRUE;
@ -276,17 +276,14 @@ repo_prune_internal (OstreeRepo *self,
GLNX_HASH_TABLE_FOREACH_KV (objects, GVariant*, serialized_key, GVariant*, objdata) GLNX_HASH_TABLE_FOREACH_KV (objects, GVariant*, serialized_key, GVariant*, objdata)
{ {
const char *checksum;
OstreeObjectType objtype;
gboolean is_loose; gboolean is_loose;
ostree_object_name_deserialize (serialized_key, &checksum, &objtype);
g_variant_get_child (objdata, 0, "b", &is_loose); g_variant_get_child (objdata, 0, "b", &is_loose);
if (!is_loose) if (!is_loose)
continue; continue;
if (!maybe_prune_loose_object (&data, options->flags, checksum, objtype, if (!maybe_prune_loose_object (&data, options->flags, serialized_key,
cancellable, error)) cancellable, error))
return FALSE; return FALSE;
} }