mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
DRY, moved case inside loop
This commit is contained in:
parent
a5aea42bc9
commit
5def1010c7
39
_imaging.c
39
_imaging.c
|
@ -393,35 +393,28 @@ getlist(PyObject* arg, int* length, const char* wrong_length, int type)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case TYPE_UINT8:
|
||||
for (i = 0; i < n; i++) {
|
||||
op = PySequence_Fast_GET_ITEM(seq, i);
|
||||
for (i = 0; i < n; i++) {
|
||||
op = PySequence_Fast_GET_ITEM(seq, i);
|
||||
// DRY, branch prediction is going to work _really_ well
|
||||
// on this switch. And 3 fewer loops to copy/paste.
|
||||
switch (type) {
|
||||
case TYPE_UINT8:
|
||||
itemp = PyInt_AsLong(op);
|
||||
((UINT8*)list)[i] = CLIP(itemp);
|
||||
}
|
||||
break;
|
||||
case TYPE_INT32:
|
||||
for (i = 0; i < n; i++) {
|
||||
op = PySequence_Fast_GET_ITEM(seq, i);
|
||||
break;
|
||||
case TYPE_INT32:
|
||||
itemp = PyInt_AsLong(op);
|
||||
((INT32*)list)[i] = itemp;
|
||||
}
|
||||
break;
|
||||
case TYPE_FLOAT32:
|
||||
for (i = 0; i < n; i++) {
|
||||
op = PySequence_Fast_GET_ITEM(seq, i);
|
||||
dtemp = PyFloat_AsDouble(op);
|
||||
((FLOAT32*)list)[i] = (FLOAT32) dtemp;
|
||||
}
|
||||
break;
|
||||
case TYPE_DOUBLE:
|
||||
for (i = 0; i < n; i++) {
|
||||
op = PySequence_Fast_GET_ITEM(seq, i);
|
||||
break;
|
||||
case TYPE_FLOAT32:
|
||||
dtemp = PyFloat_AsDouble(op);
|
||||
((FLOAT32*)list)[i] = (FLOAT32) dtemp;
|
||||
break;
|
||||
case TYPE_DOUBLE:
|
||||
dtemp = PyFloat_AsDouble(op);
|
||||
((double*)list)[i] = (double) dtemp;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (length)
|
||||
|
|
Loading…
Reference in New Issue
Block a user