<div dir="ltr">Please ignore these two patches. I think I will go another route.<br></div><br><div class="gmail_quote">On Fri, May 8, 2015 at 2:32 PM Martin von Zweigbergk <<a href="mailto:martinvonz@google.com">martinvonz@google.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Martin von Zweigbergk <<a href="mailto:martinvonz@google.com" target="_blank">martinvonz@google.com</a>><br>
# Date 1431119592 25200<br>
#      Fri May 08 14:13:12 2015 -0700<br>
# Node ID 4885053a1ec3e85d79778bd877b6a29046b18d48<br>
# Parent  e8751ee69e5fdcd26ff58af3510a390dee7bacf6<br>
dirs.c: pass C string, not Python string, to _finddir()<br>
<br>
The callers already have the C string, and although the<br>
PyString_AS_STRING() macro is probably free, this simplifies the code.<br>
<br>
diff -r e8751ee69e5f -r 4885053a1ec3 mercurial/dirs.c<br>
--- a/mercurial/dirs.c  Fri May 08 14:11:00 2015 -0700<br>
+++ b/mercurial/dirs.c  Fri May 08 14:13:12 2015 -0700<br>
@@ -29,12 +29,10 @@<br>
        PyObject *dict;<br>
 } dirsObject;<br>
<br>
-static inline Py_ssize_t _finddir(PyObject *path, Py_ssize_t pos)<br>
+static inline Py_ssize_t _finddir(const char *path, Py_ssize_t pos)<br>
 {<br>
-       const char *s = PyString_AS_STRING(path);<br>
-<br>
-       const char *ret = strchr(s + pos, '/');<br>
-       return (ret != NULL) ? (ret - s) : -1;<br>
+       const char *ret = strchr(path + pos, '/');<br>
+       return (ret != NULL) ? (ret - path) : -1;<br>
 }<br>
<br>
 static int _addpath(PyObject *dirs, PyObject *path)<br>
@@ -45,7 +43,7 @@<br>
        PyObject *key = NULL;<br>
        int ret = -1;<br>
<br>
-       while ((pos = _finddir(path, pos + 1)) != -1) {<br>
+       while ((pos = _finddir(cpath, pos + 1)) != -1) {<br>
                PyObject *val;<br>
<br>
                /* It's likely that every prefix already has an entry<br>
@@ -112,7 +110,7 @@<br>
        PyObject *key = NULL;<br>
        int ret = -1;<br>
<br>
-       while ((pos = _finddir(path, pos + 1)) != -1) {<br>
+       while ((pos = _finddir(cpath, pos + 1)) != -1) {<br>
                PyObject *val;<br>
<br>
                key = PyString_FromStringAndSize(cpath, pos);<br>
</blockquote></div>