未验证 提交 9ab00ef5 编写于 作者: S Stephen Toub 提交者: GitHub

Use LastIndexOf in ZipArchiveEntry.GetFileName_Unix (#70701)

There's not particularly good reason to open-code the loop here.
上级 f25caab2
......@@ -1104,11 +1104,10 @@ private static string GetFileName_Windows(string path)
/// </summary>
private static string GetFileName_Unix(string path)
{
int length = path.Length;
for (int i = length; --i >= 0;)
if (path[i] == '/')
return path.Substring(i + 1);
return path;
int i = path.LastIndexOf('/');
return i >= 0 ?
path.Substring(i + 1) :
path;
}
private sealed class DirectToArchiveWriterStream : Stream
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册