]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
move do_title to a better place
authorBenjamin Peterson <benjamin@python.org>
Fri, 13 Jan 2012 02:10:29 +0000 (21:10 -0500)
committerBenjamin Peterson <benjamin@python.org>
Fri, 13 Jan 2012 02:10:29 +0000 (21:10 -0500)
Objects/unicodeobject.c

index 034c6916369a2d8833a44b8a6d27b595a622987f..471d98b0f3b9908a5f42e3c91e25ab270c2e58f8 100644 (file)
@@ -9576,6 +9576,34 @@ do_lower(int kind, void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *maxchar
     return do_upper_or_lower(kind, data, length, res, maxchar, 1);
 }
 
+static Py_ssize_t
+do_title(int kind, void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *maxchar)
+{
+    Py_ssize_t i, k = 0;
+    int previous_is_cased;
+
+    previous_is_cased = 0;
+    for (i = 0; i < length; i++) {
+        const Py_UCS4 c = PyUnicode_READ(kind, data, i);
+        Py_UCS4 mapped[3];
+        int n_res, j;
+
+        if (previous_is_cased)
+            n_res = lower_ucs4(kind, data, length, i, c, mapped);
+        else
+            n_res = _PyUnicode_ToTitleFull(c, mapped);
+
+        for (j = 0; j < n_res; j++) {
+            if (mapped[j] > *maxchar)
+                *maxchar = mapped[j];
+            res[k++] = mapped[j];
+        }
+
+        previous_is_cased = _PyUnicode_IsCased(c);
+    }
+    return k;
+}
+
 static PyObject *
 case_operation(PyObject *self,
                Py_ssize_t (*perform)(int, void *, Py_ssize_t, Py_UCS4 *, Py_UCS4 *))
@@ -9621,34 +9649,6 @@ case_operation(PyObject *self,
     return res;
 }
 
-static Py_ssize_t
-do_title(int kind, void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *maxchar)
-{
-    Py_ssize_t i, k = 0;
-    int previous_is_cased;
-
-    previous_is_cased = 0;
-    for (i = 0; i < length; i++) {
-        const Py_UCS4 c = PyUnicode_READ(kind, data, i);
-        Py_UCS4 mapped[3];
-        int n_res, j;
-
-        if (previous_is_cased)
-            n_res = lower_ucs4(kind, data, length, i, c, mapped);
-        else
-            n_res = _PyUnicode_ToTitleFull(c, mapped);
-
-        for (j = 0; j < n_res; j++) {
-            if (mapped[j] > *maxchar)
-                *maxchar = mapped[j];
-            res[k++] = mapped[j];
-        }
-
-        previous_is_cased = _PyUnicode_IsCased(c);
-    }
-    return k;
-}
-
 PyObject *
 PyUnicode_Join(PyObject *separator, PyObject *seq)
 {