mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-06-07 19:58:50 +00:00
backend_firefox, fs_ops: store hashcode in entry
Trade a bit of memory for hashmap rehash/remove efficiency.
This commit is contained in:
parent
3e6bcb8b4f
commit
85b02f6c2b
2 changed files with 13 additions and 6 deletions
|
@ -162,9 +162,11 @@ struct bookmark_lcookie {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bookmark_dentry {
|
struct bookmark_dentry {
|
||||||
uint64_t id;
|
uint64_t id;
|
||||||
size_t name_len;
|
unsigned long hashcode;
|
||||||
char name[];
|
|
||||||
|
size_t name_len;
|
||||||
|
char name[];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bookmark_name_key {
|
struct bookmark_name_key {
|
||||||
|
@ -530,6 +532,7 @@ fsck_apply (
|
||||||
|
|
||||||
dentry = xmalloc(sizeof(*dentry) + name_len);
|
dentry = xmalloc(sizeof(*dentry) + name_len);
|
||||||
dentry->id = id;
|
dentry->id = id;
|
||||||
|
dentry->hashcode = hashcode;
|
||||||
dentry->name_len = name_len;
|
dentry->name_len = name_len;
|
||||||
memcpy(dentry->name, name, name_len);
|
memcpy(dentry->name, name, name_len);
|
||||||
|
|
||||||
|
@ -2454,6 +2457,7 @@ bookmark_list_cb (
|
||||||
if (ctx->status == 0 && ctx->check_name && dentry == NULL) {
|
if (ctx->status == 0 && ctx->check_name && dentry == NULL) {
|
||||||
dentry = xmalloc(sizeof(*dentry) + name_len);
|
dentry = xmalloc(sizeof(*dentry) + name_len);
|
||||||
dentry->id = id;
|
dentry->id = id;
|
||||||
|
dentry->hashcode = hashcode;
|
||||||
dentry->name_len = name_len;
|
dentry->name_len = name_len;
|
||||||
memcpy(dentry->name, name, name_len);
|
memcpy(dentry->name, name, name_len);
|
||||||
|
|
||||||
|
@ -2522,7 +2526,7 @@ dentmap_hash (
|
||||||
) {
|
) {
|
||||||
struct bookmark_dentry const *dentry = entry;
|
struct bookmark_dentry const *dentry = entry;
|
||||||
|
|
||||||
return hash_digest(dentry->name, dentry->name_len);
|
return dentry->hashcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -126,7 +126,9 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fs_file_handle {
|
struct fs_file_handle {
|
||||||
uint64_t id;
|
uint64_t id;
|
||||||
|
unsigned long hashcode;
|
||||||
|
|
||||||
uint32_t refcount;
|
uint32_t refcount;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
|
|
||||||
|
@ -491,6 +493,7 @@ bm_fh_new (
|
||||||
fh = xmalloc(sizeof(*fh));
|
fh = xmalloc(sizeof(*fh));
|
||||||
*fh = (struct fs_file_handle) {
|
*fh = (struct fs_file_handle) {
|
||||||
.id = id,
|
.id = id,
|
||||||
|
.hashcode = hashcode,
|
||||||
.refcount = 1,
|
.refcount = 1,
|
||||||
};
|
};
|
||||||
hashmap_insert(ctx.fh_map, hashcode, fh);
|
hashmap_insert(ctx.fh_map, hashcode, fh);
|
||||||
|
@ -1285,7 +1288,7 @@ fh_entry_hash (
|
||||||
) {
|
) {
|
||||||
struct fs_file_handle const *fh = entry;
|
struct fs_file_handle const *fh = entry;
|
||||||
|
|
||||||
return hash_digest(&fh->id, sizeof(fuse_ino_t));
|
return fh->hashcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Reference in a new issue