diff options
| author | Mohit Agrawal <moagrawa@redhat.com> | 2020-07-25 11:28:43 +0530 |
|---|---|---|
| committer | MOHIT AGRAWAL <moagrawa@redhat.com> | 2020-07-31 06:06:03 +0000 |
| commit | dbff4ecfc18d4d4ad357e2f53806a6caf69d2b65 (patch) | |
| tree | 41c18e03c3950474e82cf3f3597cdf044d6f7165 /libglusterfs/src/glusterfs | |
| parent | 3204091c850a92f492c8f89099c1ecebb502d01f (diff) | |
dict: optimize dict_serialized_length_lk function
To return the length of searlized dictionary the function
iterates full dictionary and access every key value member
of the dictionary.Instead of iterating full dictionary introduce
a variable totkvlen at dictionary to save the key value length
at the time of storing key/value pair in the dictionary.
Change-Id: Ie8cfdea1cc335bce51f59179281df3c89afab68b
Fixes: #1395
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Diffstat (limited to 'libglusterfs/src/glusterfs')
| -rw-r--r-- | libglusterfs/src/glusterfs/dict.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libglusterfs/src/glusterfs/dict.h b/libglusterfs/src/glusterfs/dict.h index ce1c2100276..d4bf9b4f1a7 100644 --- a/libglusterfs/src/glusterfs/dict.h +++ b/libglusterfs/src/glusterfs/dict.h @@ -98,7 +98,7 @@ struct _data { char *data; gf_atomic_t refcount; gf_dict_data_type_t data_type; - int32_t len; + uint32_t len; gf_boolean_t is_static; }; @@ -122,6 +122,8 @@ struct _dict { gf_lock_t lock; data_pair_t *members_internal; data_pair_t free_pair; + /* Variable to store total keylen + value->len */ + uint32_t totkvlen; }; typedef gf_boolean_t (*dict_match_t)(dict_t *d, char *k, data_t *v, void *data); |
