Skip to content

Commit

Permalink
modules/kvs: Cleanup code in commit_unroll()
Browse files Browse the repository at this point in the history
With RFC11 changes, we always know the data in a treeobj val object
is a base64 encoded string.  Therefore, we do not need to call
kvs_util_json_encoded_size to get the encoded size.  We just
need to call strlen() on the string value.
  • Loading branch information
chu11 committed Nov 3, 2017
1 parent 4b1eacc commit 036ed34
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/modules/kvs/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,14 @@ static int commit_unroll (commit_t *c, int current_epoch, json_t *dir)
}
else if (treeobj_is_val (dir_entry)) {
json_t *val_data;
size_t size;
const char *str;

if (!(val_data = treeobj_get_data (dir_entry)))
return -1;
if (kvs_util_json_encoded_size (val_data, &size) < 0)
return -1;
if (size > BLOBREF_MAX_STRING_SIZE) {
/* jansson >= 2.7 could use json_string_length() instead */
str = json_string_value (val_data);
assert (str);
if (strlen (str) > BLOBREF_MAX_STRING_SIZE) {
if ((ret = store_cache (c, current_epoch, val_data,
true, ref, &hp)) < 0)
return -1;
Expand Down

0 comments on commit 036ed34

Please sign in to comment.