Slight optimisation

This commit is contained in:
rdb 2011-03-30 07:20:26 +00:00
parent 0955c464ab
commit e461c21c56

View File

@ -885,7 +885,8 @@ set_ram_image_as(CPTA_uchar image, const string &supplied_format) {
PTA_uchar newdata = PTA_uchar::empty_array(imgsize * _num_components * _component_width, get_class_type());
// These ifs are for optimization of commonly used image types.
if (format == "RGBA" && _num_components == 4 && _component_width == 1) {
if (_component_width == 1) {
if (format == "RGBA" && _num_components == 4) {
imgsize *= 4;
for (int p = 0; p < imgsize; p += 4) {
newdata[p + 2] = image[p ];
@ -896,7 +897,7 @@ set_ram_image_as(CPTA_uchar image, const string &supplied_format) {
set_ram_image(newdata);
return;
}
if (format == "RGB" && _num_components == 3 && _component_width == 1) {
if (format == "RGB" && _num_components == 3) {
imgsize *= 3;
for (int p = 0; p < imgsize; p += 3) {
newdata[p + 2] = image[p ];
@ -906,7 +907,7 @@ set_ram_image_as(CPTA_uchar image, const string &supplied_format) {
set_ram_image(newdata);
return;
}
if (format == "A" && _component_width == 1 && _num_components != 3) {
if (format == "A" && _num_components != 3) {
// We can generally rely on alpha to be the last component.
int component = _num_components - 1;
for (int p = 0; p < imgsize; ++p) {
@ -915,7 +916,6 @@ set_ram_image_as(CPTA_uchar image, const string &supplied_format) {
set_ram_image(newdata);
return;
}
if (_component_width == 1) {
for (int p = 0; p < imgsize; ++p) {
for (uchar s = 0; s < format.size(); ++s) {
signed char component = -1;