]> granicus.if.org Git - python/commitdiff
Issue #13738: Simplify implementation of bytes.lower() and bytes.upper().
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 8 Jan 2012 15:22:46 +0000 (16:22 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 8 Jan 2012 15:22:46 +0000 (16:22 +0100)
Misc/NEWS
Objects/bytes_methods.c

index fbc6f670a2a688861c3a54a6d20e44084b4817e6..d8ffec45a7ee927f2b720a500961faf87864f918 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ What's New in Python 3.3 Alpha 1?
 Core and Builtins
 -----------------
 
+- Issue #13738: Simplify implementation of bytes.lower() and bytes.upper().
+
 - Issue #13577: Built-in methods and functions now have a __qualname__.
   Patch by sbt.
 
index 7233cea40957f18ffe96e48bd7da28d159d6e429..ef3c2f729da636440a5d2b22cdbc6e646a162204 100644 (file)
@@ -248,12 +248,8 @@ _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len)
 {
     Py_ssize_t i;
 
-    Py_MEMCPY(result, cptr, len);
-
     for (i = 0; i < len; i++) {
-        int c = Py_CHARMASK(result[i]);
-        if (Py_ISUPPER(c))
-            result[i] = Py_TOLOWER(c);
+        result[i] = Py_TOLOWER((unsigned char) cptr[i]);
     }
 }
 
@@ -268,12 +264,8 @@ _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len)
 {
     Py_ssize_t i;
 
-    Py_MEMCPY(result, cptr, len);
-
     for (i = 0; i < len; i++) {
-        int c = Py_CHARMASK(result[i]);
-        if (Py_ISLOWER(c))
-            result[i] = Py_TOUPPER(c);
+        result[i] = Py_TOUPPER((unsigned char) cptr[i]);
     }
 }