summaryrefslogtreecommitdiffstats
path: root/Modules/stropmodule.c
diff options
context:
space:
mode:
authorSjoerd Mullender <sjoerd@acm.org>1993-10-22 12:04:32 (GMT)
committerSjoerd Mullender <sjoerd@acm.org>1993-10-22 12:04:32 (GMT)
commit3bb8a05947fb67ed827dd1e8d7c0a982a1ff989e (patch)
treecb9c4f6b18f70822ade606f269fc043be542f5da /Modules/stropmodule.c
parenta75d306e2b799aa891666899ca973bec82b2362b (diff)
downloadcpython-3bb8a05947fb67ed827dd1e8d7c0a982a1ff989e.zip
cpython-3bb8a05947fb67ed827dd1e8d7c0a982a1ff989e.tar.gz
cpython-3bb8a05947fb67ed827dd1e8d7c0a982a1ff989e.tar.bz2
Several optimizations and speed improvements.
cstubs: Use Matrix type instead of float[4][4].
Diffstat (limited to 'Modules/stropmodule.c')
-rw-r--r--Modules/stropmodule.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index 6686abf..3a941a8 100644
--- a/Modules/stropmodule.c
+++ b/Modules/stropmodule.c
@@ -254,24 +254,26 @@ strop_lower(self, args)
object *self; /* Not used */
object *args;
{
- char *s;
+ char *s, *s_new;
int i, n;
object *new;
int changed;
if (!getargs(args, "s#", &s, &n))
return NULL;
- new = newsizedstringobject(s, n);
+ new = newsizedstringobject(NULL, n);
if (new == NULL)
return NULL;
- s = getstringvalue(new);
+ s_new = getstringvalue(new);
changed = 0;
for (i = 0; i < n; i++) {
- char c = s[i];
+ char c = *s++;
if (isupper(c)) {
changed = 1;
- s[i] = tolower(c);
- }
+ *s_new = tolower(c);
+ } else
+ *s_new = c;
+ s_new++;
}
if (!changed) {
DECREF(new);
@@ -287,24 +289,26 @@ strop_upper(self, args)
object *self; /* Not used */
object *args;
{
- char *s;
+ char *s, *s_new;
int i, n;
object *new;
int changed;
if (!getargs(args, "s#", &s, &n))
return NULL;
- new = newsizedstringobject(s, n);
+ new = newsizedstringobject(NULL, n);
if (new == NULL)
return NULL;
- s = getstringvalue(new);
+ s_new = getstringvalue(new);
changed = 0;
for (i = 0; i < n; i++) {
- char c = s[i];
+ char c = *s++;
if (islower(c)) {
changed = 1;
- s[i] = toupper(c);
- }
+ *s_new = toupper(c);
+ } else
+ *s_new = c;
+ s_new++;
}
if (!changed) {
DECREF(new);
@@ -320,28 +324,31 @@ strop_swapcase(self, args)
object *self; /* Not used */
object *args;
{
- char *s;
+ char *s, *s_new;
int i, n;
object *new;
int changed;
if (!getargs(args, "s#", &s, &n))
return NULL;
- new = newsizedstringobject(s, n);
+ new = newsizedstringobject(NULL, n);
if (new == NULL)
return NULL;
- s = getstringvalue(new);
+ s_new = getstringvalue(new);
changed = 0;
for (i = 0; i < n; i++) {
- char c = s[i];
+ char c = *s++;
if (islower(c)) {
changed = 1;
- s[i] = toupper(c);
+ *s_new = toupper(c);
}
else if (isupper(c)) {
changed = 1;
- s[i] = tolower(c);
+ *s_new = tolower(c);
}
+ else
+ *s_new = c;
+ s_new++;
}
if (!changed) {
DECREF(new);