summaryrefslogtreecommitdiff
path: root/libcaja-private/caja-directory-async.c
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2026-07-30 16:57:06 -0400
committerVictor Kareh <[email protected]>2026-07-30 16:57:06 -0400
commit46c136af6bd8e1b0de504320e8a071dc679d78fa (patch)
tree2012c994202d3c298d71b8f80a0f7f18eff238f5 /libcaja-private/caja-directory-async.c
parent1914317070388726b7889e6905e787f527f08592 (diff)
downloadcaja-directory-async-performance.tar.bz2
caja-directory-async-performance.tar.xz
directory-async: Use hash set instead of an arraydirectory-async-performance
For tracking existing inodes. This gives a 4x performance boost for counting files in the home directory in my testing. Backport of https://gitlab.gnome.org/GNOME/nautilus/commit/4ef8b232 Fixes #1900
Diffstat (limited to 'libcaja-private/caja-directory-async.c')
-rw-r--r--libcaja-private/caja-directory-async.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/libcaja-private/caja-directory-async.c b/libcaja-private/caja-directory-async.c
index 85045cff..affa32e3 100644
--- a/libcaja-private/caja-directory-async.c
+++ b/libcaja-private/caja-directory-async.c
@@ -147,7 +147,7 @@ struct DeepCountState
GFileEnumerator *enumerator;
GFile *deep_count_location;
GList *deep_count_subdirectories;
- GArray *seen_deep_count_inodes;
+ GHashTable *seen_deep_count_inodes;
char *fs_id;
};
@@ -2821,21 +2821,13 @@ static inline gboolean
seen_inode (DeepCountState *state,
GFileInfo *info)
{
- guint64 inode, inode2;
- guint i;
+ guint64 inode;
inode = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_UNIX_INODE);
if (inode != 0)
{
- for (i = 0; i < state->seen_deep_count_inodes->len; i++)
- {
- inode2 = g_array_index (state->seen_deep_count_inodes, guint64, i);
- if (inode == inode2)
- {
- return TRUE;
- }
- }
+ return g_hash_table_lookup (state->seen_deep_count_inodes, &inode) != NULL;
}
return FALSE;
@@ -2850,7 +2842,9 @@ mark_inode_as_seen (DeepCountState *state,
inode = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_UNIX_INODE);
if (inode != 0)
{
- g_array_append_val (state->seen_deep_count_inodes, inode);
+ guint64 *key = g_new (guint64, 1);
+ *key = inode;
+ g_hash_table_add (state->seen_deep_count_inodes, key);
}
}
@@ -2925,7 +2919,7 @@ deep_count_state_free (DeepCountState *state)
g_object_unref (state->deep_count_location);
}
g_list_free_full (state->deep_count_subdirectories, g_object_unref);
- g_array_free (state->seen_deep_count_inodes, TRUE);
+ g_hash_table_unref (state->seen_deep_count_inodes);
g_free (state->fs_id);
g_free (state);
}
@@ -3189,7 +3183,7 @@ deep_count_start (CajaDirectory *directory,
state = g_new0 (DeepCountState, 1);
state->directory = directory;
state->cancellable = g_cancellable_new ();
- state->seen_deep_count_inodes = g_array_new (FALSE, TRUE, sizeof (guint64));
+ state->seen_deep_count_inodes = g_hash_table_new_full (g_int64_hash, g_int64_equal, g_free, NULL);
state->fs_id = NULL;
directory->details->deep_count_in_progress = state;