Skip to content

Commit

Permalink
lib-storage: Don't add trailing NUL to strings in dovecot.index.cache
Browse files Browse the repository at this point in the history
They are unnecessary and just unnecessarily consume disk space. The
existing reading code works even if they don't exist, so this change won't
break backwards compatibility.
  • Loading branch information
sirainen authored and cmouse committed Apr 23, 2018
1 parent d8449ed commit 955384f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib-storage/index/dbox-common/dbox-mail.c
Expand Up @@ -203,7 +203,7 @@ dbox_get_cached_metadata(struct dbox_mail *mail, enum dbox_metadata_key key,
value = "";
if (cache_field != MAIL_CACHE_POP3_ORDER) {
index_mail_cache_add_idx(imail, ibox->cache_fields[cache_field].idx,
value, strlen(value)+1);
value, strlen(value));
} else {
if (str_to_uint(value, &order) < 0)
order = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/lib-storage/index/imapc/imapc-mail.c
Expand Up @@ -501,7 +501,7 @@ static bool imapc_mail_get_cached_guid(struct mail *_mail)
_mail->seq, cache_idx)) {
/* GUID was prefetched - add to cache */
index_mail_cache_add_idx(imail, cache_idx,
imail->data.guid, strlen(imail->data.guid)+1);
imail->data.guid, strlen(imail->data.guid));
}
return TRUE;
}
Expand Down Expand Up @@ -542,7 +542,7 @@ static int imapc_mail_get_guid(struct mail *_mail, const char **value_r)
}

index_mail_cache_add_idx(imail, cache_idx,
imail->data.guid, strlen(imail->data.guid)+1);
imail->data.guid, strlen(imail->data.guid));
*value_r = imail->data.guid;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib-storage/index/imapc/imapc-mailbox.c
Expand Up @@ -592,7 +592,7 @@ static void imapc_untagged_fetch(const struct imapc_untagged_reply *reply,
if (mail_cache_field_can_add(mbox->delayed_sync_cache_trans,
lseq, guid_cache_idx)) {
mail_cache_add(mbox->delayed_sync_cache_trans, lseq,
guid_cache_idx, guid, strlen(guid)+1);
guid_cache_idx, guid, strlen(guid));
}
}
imapc_mailbox_idle_notify(mbox);
Expand Down
8 changes: 4 additions & 4 deletions src/lib-storage/index/index-mail.c
Expand Up @@ -779,7 +779,7 @@ index_mail_body_parsed_cache_bodystructure(struct index_mail *mail,
data->bodystructure = str_c(str);

index_mail_cache_add(mail, MAIL_CACHE_IMAP_BODYSTRUCTURE,
str_c(str), str_len(str)+1);
str_c(str), str_len(str));
bodystructure_cached = TRUE;
} else {
bodystructure_cached =
Expand Down Expand Up @@ -811,7 +811,7 @@ index_mail_body_parsed_cache_bodystructure(struct index_mail *mail,
data->body = str_c(str);

index_mail_cache_add(mail, MAIL_CACHE_IMAP_BODY,
str_c(str), str_len(str)+1);
str_c(str), str_len(str));
}
}

Expand Down Expand Up @@ -873,7 +873,7 @@ static void index_mail_save_finish_make_snippet(struct index_mail *mail)
index_mail_want_cache(mail, MAIL_CACHE_BODY_SNIPPET)) {
index_mail_cache_add(mail, MAIL_CACHE_BODY_SNIPPET,
mail->data.body_snippet,
strlen(mail->data.body_snippet)+1);
strlen(mail->data.body_snippet));
}
}

Expand Down Expand Up @@ -1365,7 +1365,7 @@ static int index_mail_parse_bodystructure(struct index_mail *mail,
if (index_mail_want_cache(mail, MAIL_CACHE_BODY_SNIPPET))
index_mail_cache_add(mail, MAIL_CACHE_BODY_SNIPPET,
mail->data.body_snippet,
strlen(mail->data.body_snippet) + 1);
strlen(mail->data.body_snippet));
}
i_assert(data->body_snippet != NULL &&
data->body_snippet[0] != '\0');
Expand Down
2 changes: 1 addition & 1 deletion src/lib-storage/index/pop3c/pop3c-sync.c
Expand Up @@ -248,7 +248,7 @@ pop3c_sync_messages(struct pop3c_mailbox *mbox,
mail_index_append(sync_trans, next_uid++, &lseq);
mail_cache_add(cache_trans, lseq, cache_idx,
rmsg[ridx].uidl,
strlen(rmsg[ridx].uidl)+1);
strlen(rmsg[ridx].uidl));
ridx++;
} else {
/* UIDL matched */
Expand Down

0 comments on commit 955384f

Please sign in to comment.