parsers: change the type signature of hexdigit
authorBryan O'Sullivan <bryano@fb.com>
Tue, 08 May 2012 14:48:48 -0700
changeset 16617 4fb16743049d
parent 16616 8f79aabd96f6
child 16618 6bae941b58ad
parsers: change the type signature of hexdigit An upcoming change will make use of this.
mercurial/parsers.c
--- a/mercurial/parsers.c	Tue May 08 14:48:44 2012 -0700
+++ b/mercurial/parsers.c	Tue May 08 14:48:48 2012 -0700
@@ -13,8 +13,10 @@
 
 #include "util.h"
 
-static int hexdigit(char c)
+static inline int hexdigit(const char *p, Py_ssize_t off)
 {
+	char c = p[off];
+
 	if (c >= '0' && c <= '9')
 		return c - '0';
 	if (c >= 'a' && c <= 'f')
@@ -32,8 +34,8 @@
 static PyObject *unhexlify(const char *str, int len)
 {
 	PyObject *ret;
-	const char *c;
 	char *d;
+	int i;
 
 	ret = PyBytes_FromStringAndSize(NULL, len / 2);
 
@@ -42,9 +44,9 @@
 
 	d = PyBytes_AsString(ret);
 
-	for (c = str; c < str + len;) {
-		int hi = hexdigit(*c++);
-		int lo = hexdigit(*c++);
+	for (i = 0; i < len;) {
+		int hi = hexdigit(str, i++);
+		int lo = hexdigit(str, i++);
 		*d++ = (hi << 4) | lo;
 	}