Much appreciated reply - I didn't even think of the [ @$_[1] ] construct - that should save a lot of clone() calls - I'll test asap.
BTW, as way of explanation, the _atlayer sub basically 'layers' the attributes of the current "character" onto the already-existing attributes at the position. First arg to _atlayer is existing attributes, second arg is 'new' attributes. The clone/copy of the new atrributes is necessary because the 'new' attributes are stored as an array ref in the object - a la the current 'brush' in a Qt painter. I can't just modify the "brush" array ref - must copy first, else the master "brush" would be modified for all subsequent calls.
The 'layering' mentioned basically says that if there are no attributes in the "brush" (e.g. the -1 or the undef), then apply attributes from the existing attribute ref, but if the brush has any attributes for that category (even an 'off' flag, such as for bold - which would make the final output have a DIM ansi code) the value sent in the second argument will take precedents over the existing attribute at that location.
Whew..*takes a breath * ... sorry, complicated explanation for what is actually kinda simple. Does it make sense?
In reply to Re^2: Optimizing a Text Canvas: An inner loop and a cloner
by JosiahBryan
in thread Optimizing a Text Canvas: An inner loop and a cloner
by JosiahBryan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |