backend_firefox, fs_ops: store hashcode in entry

Trade a bit of memory for hashmap rehash/remove efficiency.
This commit is contained in:
CismonX 2025-03-09 15:44:29 +08:00
parent 3e6bcb8b4f
commit 85b02f6c2b
No known key found for this signature in database
GPG key ID: 3094873E29A482FB
2 changed files with 13 additions and 6 deletions

View file

@ -162,9 +162,11 @@ struct bookmark_lcookie {
};
struct bookmark_dentry {
uint64_t id;
size_t name_len;
char name[];
uint64_t id;
unsigned long hashcode;
size_t name_len;
char name[];
};
struct bookmark_name_key {
@ -530,6 +532,7 @@ fsck_apply (
dentry = xmalloc(sizeof(*dentry) + name_len);
dentry->id = id;
dentry->hashcode = hashcode;
dentry->name_len = name_len;
memcpy(dentry->name, name, name_len);
@ -2454,6 +2457,7 @@ bookmark_list_cb (
if (ctx->status == 0 && ctx->check_name && dentry == NULL) {
dentry = xmalloc(sizeof(*dentry) + name_len);
dentry->id = id;
dentry->hashcode = hashcode;
dentry->name_len = name_len;
memcpy(dentry->name, name, name_len);
@ -2522,7 +2526,7 @@ dentmap_hash (
) {
struct bookmark_dentry const *dentry = entry;
return hash_digest(dentry->name, dentry->name_len);
return dentry->hashcode;
}
static void

View file

@ -126,7 +126,9 @@ enum {
};
struct fs_file_handle {
uint64_t id;
uint64_t id;
unsigned long hashcode;
uint32_t refcount;
uint32_t flags;
@ -491,6 +493,7 @@ bm_fh_new (
fh = xmalloc(sizeof(*fh));
*fh = (struct fs_file_handle) {
.id = id,
.hashcode = hashcode,
.refcount = 1,
};
hashmap_insert(ctx.fh_map, hashcode, fh);
@ -1285,7 +1288,7 @@ fh_entry_hash (
) {
struct fs_file_handle const *fh = entry;
return hash_digest(&fh->id, sizeof(fuse_ino_t));
return fh->hashcode;
}
static int