On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote:
Greetings!
I have this code,
First option...
foreach (...)
{
if (std.string.tolower(fext[0]) == "doc" ||
std.string.tolower(fext[0]) == "docx" ||
std.string.tolower(fext[0]) == "xls" ||
std.string.tolower(fext[0]) == "xlsx" ||
std.string.tolower(fext[0]) == "ppt" ||
std.string.tolower(fext[0]) == "pptx")
continue;
}
Second option...
foreach (...)
{
if (std.string.tolower(fext[0]) == "doc")
continue;
if (std.string.tolower(fext[0]) == "docx")
continue;
if (std.string.tolower(fext[0]) == "xls")
continue;
if (std.string.tolower(fext[0]) == "xlsx")
continue;
if (std.string.tolower(fext[0]) == "ppt")
continue;
if (std.string.tolower(fext[0]) == "pptx")
continue;
...
...
}
thanks.
josé
So, after I saw this post I asked myself, what? So, the question
is: which of the two foreach loops options are faster:
1. The concatenated if ||
2. The single if
I am trying to see if it matters. I have a project with lots of
files and if one is faster, then, it will matter to code it the
faster way. Thanks.