In general, when comparing variables in templates, I use unquoted variable names. e.g.,
{if segment_3 == category_url_title}
If comparing to an actual value (not a variable), I quote the value. e.g.,
{if count == "1"}
But in some cases (within a Matrix or Playa field, for instance), the comparisons only work if you quote the parsed variable. e.g.,
{if "{row_count}" == "{total_rows}"}
So my questions is - why is this? Does it have to do with strings containing spaces vs those that are space-free (like segment variables, integers, and booleans)? Often it just seems random, which I don't like.
I've also read that there is a performance hit when comparing using quoted vs unquoted syntax. Any truth to this?