mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 14:58:03 +03:00
cext: extract revlog/index parsing code to own C file
parsers.c is ~3000 lines and ~2/3 of it is related to the revlog index type. We already have separate C source files for directory utilities and manifest parsing. I think the quite unwieldy revlog/index parsing code should be self-contained as well. I performed the extraction as a file copy then removed content from both sides in order to preserve file history and blame. As part of this, I also had to move the hexdigit table and function to a shared header since it is used by both parsers.c and revlog.c # no-check-commit
This commit is contained in:
parent
c283f56e61
commit
9e19911eaa
File diff suppressed because it is too large
Load Diff
1943
mercurial/cext/revlog.c
Normal file
1943
mercurial/cext/revlog.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -42,4 +42,35 @@ typedef unsigned char bool;
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
static int8_t hextable[256] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /* 0-9 */
|
||||
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* A-F */
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* a-f */
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
};
|
||||
|
||||
static inline int hexdigit(const char *p, Py_ssize_t off)
|
||||
{
|
||||
int8_t val = hextable[(unsigned char)p[off]];
|
||||
|
||||
if (val >= 0) {
|
||||
return val;
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_ValueError, "input contains non-hex character");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* _HG_UTIL_H_ */
|
||||
|
3
setup.py
3
setup.py
@ -638,7 +638,8 @@ extmodules = [
|
||||
Extension('mercurial.cext.parsers', ['mercurial/cext/dirs.c',
|
||||
'mercurial/cext/manifest.c',
|
||||
'mercurial/cext/parsers.c',
|
||||
'mercurial/cext/pathencode.c'],
|
||||
'mercurial/cext/pathencode.c',
|
||||
'mercurial/cext/revlog.c'],
|
||||
include_dirs=common_include_dirs,
|
||||
depends=common_depends),
|
||||
Extension('mercurial.cext.osutil', ['mercurial/cext/osutil.c'],
|
||||
|
Loading…
Reference in New Issue
Block a user