This is an archive of the discontinued Mercurial Phabricator instance.

cext: isolate hash size in the revlog handling in a single place
ClosedPublic

Authored by joerg.sonnenberger on Nov 28 2020, 5:39 PM.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

Alphare accepted this revision.Dec 7 2020, 5:18 AM
martinvonz requested changes to this revision.Dec 16 2020, 6:31 PM
martinvonz added a subscriber: martinvonz.
martinvonz added inline comments.
mercurial/cext/revlog.c
1500

Is this extra node[1] == '\0' check intentional? It seems unrelated to me. Can you move it to a separate patch?

This revision now requires changes to proceed.Dec 16 2020, 6:31 PM
mercurial/cext/revlog.c
1500

Yes, it is intentional. I've added it because unlike before, the memcmp will not be inlined automatically and therefore the original check does come with a much higher false positive rate. The explicit check is for free on all architectures with unaligned memory access.

martinvonz added inline comments.Dec 16 2020, 6:59 PM
mercurial/cext/revlog.c
1500

Okay, makes sense. That was far from obvious (to me anyway) and could probably have been mentioned in the commit message.

martinvonz accepted this revision.Dec 16 2020, 9:08 PM
This revision is now accepted and ready to land.Dec 16 2020, 9:08 PM

Can you send a followup for this warning?

mercurial/cext/revlog.c: In function 'index_init':
mercurial/cext/revlog.c:2615:42: warning: comparison of integer expressions of different signedness: 'Py_ssize_t' {aka 'long int'} and 'long unsigned int' [-Wsign-compare]
 2615 |  if (self->nodelen < 20 || self->nodelen > sizeof(nullid)) {
      |                                          ^