[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fri, 30 Apr 2004 14:11:32 +0200
do you know FxCop?
FxCop ist a kind of lint that analyzes assemblies for coding and performance
One of the fixed ideas (validation rules) of fxcop reads (this is not a
Do not test for empty string comparing it to empty string literal:
if (val == "")
use its length instead:
if (val.Length == 0)
because comparing strings (empty literal will be converted to an string
instance before comparison) is much more expensive than comaring the string
I have tested it with pnet and indeed pnet runs *val.Length == 0* two times
faster than *val == ""*.
I have not tested other runtimes because it is not always allowed :-(.
But if FxCop says so it must be true for them too.
My question is if pnet could do it better?
Especially this trivial kind of optimization could be done directly in parser.
It would have no impact on anything.
This message is utf-8 encoded
Miroslaw Dobrzanski-Neumann <=
- RE: [DotGNU]fxcop, Thong (Tum) Nguyen, 2004/04/30