in reply to Optimizing a Text Canvas: An inner loop and a cloner
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Optimizing a Text Canvas: An inner loop and a cloner
by JosiahBryan (Novice) on Jul 06, 2007 at 15:45 UTC | |
by JosiahBryan (Novice) on Jul 06, 2007 at 17:27 UTC | |
by dsheroh (Monsignor) on Jul 06, 2007 at 16:00 UTC | |
by dsheroh (Monsignor) on Jul 06, 2007 at 17:51 UTC | |
by JosiahBryan (Novice) on Jul 06, 2007 at 16:10 UTC |