我有一小段代码,每个都在使用。我已经优化了我的代码,但我的老板希望我进一步优化它。我不知道可以在这里进行哪些进一步的优化。
foreach (Match match in matches) {
//When oveeride is false and you have to download all the files
if (Override.Equals(false)) {
//putting the matches from regular expression into DownloadFileStruct oject
df = new DownloadFileStruct(match.Groups[1].Value, match.Groups[2].Value);
//Adding DownloadFileStruct object to a array list
DownloadFileList.Add(df);
}
//When override is true and a paticular file has to be downloaded
else if (match.Groups[2].Value.Equals(OverrideFileName)) {
//putting the matche from regular expression into a DownloadFileStruct oject
df = new DownloadFileStruct(match.Groups[1].Value, match.Groups[2].Value);
//Adding DownloadFileStruct object to a array list
DownloadFileList.Add(df);
}
}
}
我的老板所说的“您不需要在两个分支中执行相同代码的 'if' 和 'else if'”。