[Updated] D12177: revlog: memset whole record instead of dealing with padding
pacien (Pacien)
phabricator at mercurial-scm.org
Tue Feb 15 14:50:10 UTC 2022
Closed by commit rHG654baf1faa52: revlog: memset whole record instead of dealing with padding (authored by pacien).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12177?vs=32176&id=32206
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12177/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12177
AFFECTED FILES
mercurial/cext/revlog.c
CHANGE DETAILS
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -158,7 +158,7 @@
static const long entry_v2_offset_sidedata_offset = 64;
static const long entry_v2_offset_sidedata_comp_len = 72;
static const long entry_v2_offset_all_comp_mode = 76;
-static const long entry_v2_offset_padding_start = 77;
+/* next free offset: 77 */
static const char comp_mode_inline = 2;
static const char rank_unknown = -1;
@@ -603,6 +603,8 @@
rev = self->length + self->new_length;
data = self->added + self->entry_size * self->new_length++;
+ memset(data, 0, self->entry_size);
+
if (self->format_version == format_v1) {
putbe32(offset_flags >> 32, data + entry_v1_offset_high);
putbe32(offset_flags & 0xffffffffU,
@@ -615,9 +617,6 @@
putbe32(parent_2, data + entry_v1_offset_parent_2);
memcpy(data + entry_v1_offset_node_id, c_node_id,
c_node_id_len);
- /* Padding since SHA-1 is only 20 bytes for now */
- memset(data + entry_v1_offset_node_id + c_node_id_len, 0,
- entry_v1_offset_node_id - c_node_id_len);
} else if (self->format_version == format_v2) {
putbe32(offset_flags >> 32, data + entry_v2_offset_high);
putbe32(offset_flags & 0xffffffffU,
@@ -630,9 +629,6 @@
putbe32(parent_2, data + entry_v2_offset_parent_2);
memcpy(data + entry_v2_offset_node_id, c_node_id,
c_node_id_len);
- /* Padding since SHA-1 is only 20 bytes for now */
- memset(data + entry_v2_offset_node_id + c_node_id_len, 0,
- entry_v2_offset_node_id - c_node_id_len);
putbe64(sidedata_offset,
data + entry_v2_offset_sidedata_offset);
putbe32(sidedata_comp_len,
@@ -640,9 +636,6 @@
comp_field = data_comp_mode & 3;
comp_field = comp_field | (sidedata_comp_mode & 3) << 2;
data[entry_v2_offset_all_comp_mode] = comp_field;
- /* Padding for 96 bytes alignment */
- memset(data + entry_v2_offset_padding_start, 0,
- self->entry_size - entry_v2_offset_padding_start);
} else {
raise_revlog_error();
return NULL;
To: pacien, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220215/19cfdbcb/attachment-0002.html>
More information about the Mercurial-patches
mailing list