If it's possible to render AS_BG and AS_FG into small enough integers (i.e., if you're dealing with 16 or 256 colors instead of full-bore 24-bit color), then $curr_attribs/$last_attribs could be bitfields instead of strings, which would allow a numeric comparison and probably speed things up even more.$chr = $line->[$col] || $blank; $atr = $arow->[$col]; $array_position++; $curr_attribs = $atr->[AS_BG] . $atr->[AS_FG] . $atr->[AS_U] . $atr->[ +AS_BOLD] . $atr->[AS_BLINK]; if ($curr_attribs ne $last_attribs) { $a[$array_position] = _attr($atr) . $chr; } else { $a[$array_position] = $chr; } $last_attribs = $curr_attribs;
OK, I think I've run out of ideas... Hopefully these will improve things enough to spare you the horrors of C.
In reply to Re: Optimizing a Text Canvas: An inner loop and a cloner
by dsheroh
in thread Optimizing a Text Canvas: An inner loop and a cloner
by JosiahBryan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |