diff options
author | Benjamin Peterson <benjamin@python.org> | 2013-06-10 16:24:01 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2013-06-10 16:24:01 (GMT) |
commit | 3164f5d56570d6d6eef9dfde5e85347805eb910a (patch) | |
tree | df89b86c59ef5248d455444cdf905e722dad3048 /Objects | |
parent | a35a128accfd2b9d07029387b97995f4854bca12 (diff) | |
parent | 7e303731262b9bd7c468c943c9d8f5359be76e4b (diff) | |
download | cpython-3164f5d56570d6d6eef9dfde5e85347805eb910a.zip cpython-3164f5d56570d6d6eef9dfde5e85347805eb910a.tar.gz cpython-3164f5d56570d6d6eef9dfde5e85347805eb910a.tar.bz2 |
merge 3.3 (#18183)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 4c3ecd6..c40e9ec 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -104,11 +104,6 @@ extern "C" { #define _PyUnicode_DATA_ANY(op) \ (((PyUnicodeObject*)(op))->data.any) -/* Optimized version of Py_MAX() to compute the maximum character: - use it when your are computing the second argument of PyUnicode_New() */ -#define MAX_MAXCHAR(maxchar1, maxchar2) \ - ((maxchar1) | (maxchar2)) - #undef PyUnicode_READY #define PyUnicode_READY(op) \ (assert(_PyUnicode_CHECK(op)), \ @@ -8609,11 +8604,11 @@ fix_decimal_and_space_to_ascii(PyObject *self) } if (fixed != 0) { modified = 1; - maxchar = MAX_MAXCHAR(maxchar, fixed); + maxchar = Py_MAX(maxchar, fixed); PyUnicode_WRITE(kind, data, i, fixed); } else - maxchar = MAX_MAXCHAR(maxchar, ch); + maxchar = Py_MAX(maxchar, ch); } } @@ -8654,7 +8649,7 @@ PyUnicode_TransformDecimalToASCII(Py_UNICODE *s, int decimal = Py_UNICODE_TODECIMAL(ch); if (decimal >= 0) ch = '0' + decimal; - maxchar = MAX_MAXCHAR(maxchar, ch); + maxchar = Py_MAX(maxchar, ch); } } @@ -8895,7 +8890,7 @@ _PyUnicode_InsertThousandsGrouping( if (unicode == NULL) { *maxchar = 127; if (len != n_digits) { - *maxchar = MAX_MAXCHAR(*maxchar, + *maxchar = Py_MAX(*maxchar, PyUnicode_MAX_CHAR_VALUE(thousands_sep)); } } @@ -9289,14 +9284,14 @@ do_capitalize(int kind, void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *ma c = PyUnicode_READ(kind, data, 0); n_res = _PyUnicode_ToUpperFull(c, mapped); for (j = 0; j < n_res; j++) { - *maxchar = MAX_MAXCHAR(*maxchar, mapped[j]); + *maxchar = Py_MAX(*maxchar, mapped[j]); res[k++] = mapped[j]; } for (i = 1; i < length; i++) { c = PyUnicode_READ(kind, data, i); n_res = lower_ucs4(kind, data, length, i, c, mapped); for (j = 0; j < n_res; j++) { - *maxchar = MAX_MAXCHAR(*maxchar, mapped[j]); + *maxchar = Py_MAX(*maxchar, mapped[j]); res[k++] = mapped[j]; } } @@ -9321,7 +9316,7 @@ do_swapcase(int kind, void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *maxc mapped[0] = c; } for (j = 0; j < n_res; j++) { - *maxchar = MAX_MAXCHAR(*maxchar, mapped[j]); + *maxchar = Py_MAX(*maxchar, mapped[j]); res[k++] = mapped[j]; } } @@ -9342,7 +9337,7 @@ do_upper_or_lower(int kind, void *data, Py_ssize_t length, Py_UCS4 *res, else n_res = _PyUnicode_ToUpperFull(c, mapped); for (j = 0; j < n_res; j++) { - *maxchar = MAX_MAXCHAR(*maxchar, mapped[j]); + *maxchar = Py_MAX(*maxchar, mapped[j]); res[k++] = mapped[j]; } } @@ -9371,7 +9366,7 @@ do_casefold(int kind, void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *maxc Py_UCS4 mapped[3]; int j, n_res = _PyUnicode_ToFoldedFull(c, mapped); for (j = 0; j < n_res; j++) { - *maxchar = MAX_MAXCHAR(*maxchar, mapped[j]); + *maxchar = Py_MAX(*maxchar, mapped[j]); res[k++] = mapped[j]; } } @@ -9396,7 +9391,7 @@ do_title(int kind, void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *maxchar n_res = _PyUnicode_ToTitleFull(c, mapped); for (j = 0; j < n_res; j++) { - *maxchar = MAX_MAXCHAR(*maxchar, mapped[j]); + *maxchar = Py_MAX(*maxchar, mapped[j]); res[k++] = mapped[j]; } @@ -9551,7 +9546,7 @@ PyUnicode_Join(PyObject *separator, PyObject *seq) goto onError; sz += PyUnicode_GET_LENGTH(item); item_maxchar = PyUnicode_MAX_CHAR_VALUE(item); - maxchar = MAX_MAXCHAR(maxchar, item_maxchar); + maxchar = Py_MAX(maxchar, item_maxchar); if (i != 0) sz += seplen; if (sz < old_sz || sz > PY_SSIZE_T_MAX) { @@ -9735,7 +9730,7 @@ pad(PyObject *self, return NULL; } maxchar = PyUnicode_MAX_CHAR_VALUE(self); - maxchar = MAX_MAXCHAR(maxchar, fill); + maxchar = Py_MAX(maxchar, fill); u = PyUnicode_New(left + _PyUnicode_LENGTH(self) + right, maxchar); if (!u) return NULL; @@ -10075,7 +10070,7 @@ replace(PyObject *self, PyObject *str1, /* Replacing str1 with str2 may cause a maxchar reduction in the result string. */ mayshrink = (maxchar_str2 < maxchar_str1) && (maxchar == maxchar_str1); - maxchar = MAX_MAXCHAR(maxchar, maxchar_str2); + maxchar = Py_MAX(maxchar, maxchar_str2); if (len1 == len2) { /* same length */ @@ -10749,7 +10744,7 @@ PyUnicode_Concat(PyObject *left, PyObject *right) maxchar = PyUnicode_MAX_CHAR_VALUE(u); maxchar2 = PyUnicode_MAX_CHAR_VALUE(v); - maxchar = MAX_MAXCHAR(maxchar, maxchar2); + maxchar = Py_MAX(maxchar, maxchar2); /* Concat the two Unicode strings */ w = PyUnicode_New(new_len, maxchar); @@ -10831,7 +10826,7 @@ PyUnicode_Append(PyObject **p_left, PyObject *right) else { maxchar = PyUnicode_MAX_CHAR_VALUE(left); maxchar2 = PyUnicode_MAX_CHAR_VALUE(right); - maxchar = MAX_MAXCHAR(maxchar, maxchar2); + maxchar = Py_MAX(maxchar, maxchar2); /* Concat the two Unicode strings */ res = PyUnicode_New(new_len, maxchar); @@ -12993,7 +12988,7 @@ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer, } newlen = writer->pos + length; - maxchar = MAX_MAXCHAR(maxchar, writer->min_char); + maxchar = Py_MAX(maxchar, writer->min_char); if (writer->buffer == NULL) { assert(!writer->readonly); @@ -14133,16 +14128,16 @@ unicode_format_arg_output(struct unicode_formatter_t *ctx, if (!(arg->flags & F_LJUST)) { if (arg->sign) { if ((arg->width-1) > len) - maxchar = MAX_MAXCHAR(maxchar, fill); + maxchar = Py_MAX(maxchar, fill); } else { if (arg->width > len) - maxchar = MAX_MAXCHAR(maxchar, fill); + maxchar = Py_MAX(maxchar, fill); } } if (PyUnicode_MAX_CHAR_VALUE(str) > maxchar) { Py_UCS4 strmaxchar = _PyUnicode_FindMaxChar(str, 0, pindex+len); - maxchar = MAX_MAXCHAR(maxchar, strmaxchar); + maxchar = Py_MAX(maxchar, strmaxchar); } buflen = arg->width; |