Which is the most efficient & which is (subjectively) the most readable? (Another developer wrote the second option and I want to be sure I have a good reason for changing it to match the first option below)
Pen pen = Pens.Red;
if (highlight)
pen = new Pen(Color.Red, 3.0f);
or
Pen pen;
if (highlight)
pen = new Pen(Color.Red, 3.0f);
else
pen = Pens.Red;
I know that it makes a marginal difference, but I have a draw algorithm that needs to be literally as fast as possible! so every little bit helps. And no, using another language to handle the drawing is not an option at this point.
Thanks for the help!
var pen = highlight ? highlightPen : Pens.Red;
static readonly Pen highlightPen = new Pen(Color.Red, 3.0f);