[webkit-dev] Strings & Element Names Question
darin at apple.com
Thu Sep 24 16:30:47 PDT 2009
On Sep 24, 2009, at 3:16 PM, Eric Seidel wrote:
> Also "mfrac" being a manually typed constant counts as "copy/paste
> code" and is bad, partially because it's more error prone.
To expand on this point: If you use mfracTag, you can’t accidentally
type mfarcTag and have it compile. If you use "mfrac" you can easily
accidentally type "mfarc".
If you already know something is a MathML element then you can use
hasLocalName instead of hasTagName. The hasLocalName(mfracTag)
function is a great idea efficiency-wise, because it compiles to just
a global variable access and a pointer compare.
I think because of these two, you should use hasLocalName. You could
use hasTagName if you did not know it was a MathML element, but since
you do know you can use hasLocalName.
More information about the webkit-dev