[PATCH v2] store: rewrite fncache path mangling code in C
Adrian Buehlmann
adrian at cadifra.com
Thu Aug 30 12:32:53 CDT 2012
On 2012-08-28 19:43, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano at fb.com>
> # Date 1346175814 25200
> # Node ID 91f70954e9d681a35130aa24f66aaa7148d8ee1b
> # Parent 99a2a4ae35e2180b7f825ef2677c36d538eac4ba
> store: rewrite fncache path mangling code in C
>
> The Python path mangling code used by fncache
Ok. I got it working with the MS C compiler (and mingw32 [1]) with this
on top of your patch:
diff --git a/mercurial/pathencode.c b/mercurial/pathencode.c
--- a/mercurial/pathencode.c
+++ b/mercurial/pathencode.c
@@ -18,9 +18,18 @@
#include <Python.h>
#include <assert.h>
#include <ctype.h>
-#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <malloc.h>
+
+#ifndef _MSC_VER
+#include <stdint.h>
+#else
+#define inline __inline
+typedef unsigned char uint8_t;
+typedef unsigned __int32 uint32_t;
+#endif
+
/* state machine for the fast path */
enum path_state {
@@ -601,10 +610,10 @@
Py_ssize_t len)
{
const Py_ssize_t baselen = (len - 5) * 3;
- char dired[baselen];
- char lowered[baselen];
- char auxed[baselen];
- char mangled[baselen];
+ char* dired = alloca(baselen);
+ char* lowered = alloca(baselen);
+ char* auxed = alloca(baselen);
+ char* mangled = alloca(baselen);
Py_ssize_t dirlen, lowerlen, auxlen, destlen;
char sha[20];
[1] python setup.py build_ext -i --compiler=mingw32
More information about the Mercurial-devel
mailing list