Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
11d8e264
R
runtime
项目概览
dotNET Platform
/
runtime
12 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
11d8e264
编写于
6月 16, 2022
作者:
S
Stephen Toub
提交者:
GitHub
6月 16, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use IndexOf{Any} in a few more places (#70176)
* Use IndexOf{Any} in a few more places * Address PR feedback
上级
ae49f52e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
24 addition
and
63 deletion
+24
-63
src/libraries/System.Console/src/System/TermInfo.cs
src/libraries/System.Console/src/System/TermInfo.cs
+2
-3
src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Linux.cs
...leSystem.Watcher/src/System/IO/FileSystemWatcher.Linux.cs
+3
-8
src/libraries/System.Net.Http/src/System/Net/Http/HttpResponseMessage.cs
...ystem.Net.Http/src/System/Net/Http/HttpResponseMessage.cs
+1
-13
src/libraries/System.Net.Mail/src/System/Net/Mail/MailBnfHelper.cs
...ries/System.Net.Mail/src/System/Net/Mail/MailBnfHelper.cs
+4
-15
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/TypeNameBuilder.cs
...ate.CoreLib/src/System/Reflection/Emit/TypeNameBuilder.cs
+7
-4
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.cs
....CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.cs
+7
-20
未找到文件。
src/libraries/System.Console/src/System/TermInfo.cs
浏览文件 @
11d8e264
...
...
@@ -498,9 +498,8 @@ private static string ReadString(byte[] buffer, int pos)
/// <summary>Finds the null-terminator for a string that begins at the specified position.</summary>
private
static
int
FindNullTerminator
(
byte
[]
buffer
,
int
pos
)
{
int
termPos
=
pos
;
while
(
termPos
<
buffer
.
Length
&&
buffer
[
termPos
]
!=
'\0'
)
termPos
++;
return
termPos
;
int
i
=
buffer
.
AsSpan
(
pos
).
IndexOf
((
byte
)
'\0'
);
return
i
>=
0
?
pos
+
i
:
buffer
.
Length
;
}
}
...
...
src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Linux.cs
浏览文件 @
11d8e264
...
...
@@ -843,16 +843,11 @@ private string ReadName(int position, int nameLength)
Debug
.
Assert
(
position
>
0
);
Debug
.
Assert
(
nameLength
>=
0
&&
(
position
+
nameLength
)
<=
_buffer
.
Length
);
int
lengthWithoutNullTerm
=
nameLength
;
for
(
int
i
=
0
;
i
<
nameLength
;
i
++
)
int
lengthWithoutNullTerm
=
_buffer
.
AsSpan
(
position
,
nameLength
).
IndexOf
((
byte
)
'\0'
)
;
if
(
lengthWithoutNullTerm
<
0
)
{
if
(
_buffer
[
position
+
i
]
==
'\0'
)
{
lengthWithoutNullTerm
=
i
;
break
;
}
lengthWithoutNullTerm
=
nameLength
;
}
Debug
.
Assert
(
lengthWithoutNullTerm
<=
nameLength
);
// should be null terminated or empty
return
lengthWithoutNullTerm
>
0
?
Encoding
.
UTF8
.
GetString
(
_buffer
,
position
,
lengthWithoutNullTerm
)
:
...
...
src/libraries/System.Net.Http/src/System/Net/Http/HttpResponseMessage.cs
浏览文件 @
11d8e264
...
...
@@ -92,7 +92,7 @@ public HttpStatusCode StatusCode
}
set
{
if
((
value
!=
null
)
&&
ContainsNewLineCharacter
(
value
))
if
((
value
!=
null
)
&&
HttpRuleParser
.
ContainsNewLine
(
value
))
{
throw
new
FormatException
(
SR
.
net_http_reasonphrase_format_error
);
}
...
...
@@ -207,18 +207,6 @@ public override string ToString()
return
sb
.
ToString
();
}
private
static
bool
ContainsNewLineCharacter
(
string
value
)
{
foreach
(
char
character
in
value
)
{
if
((
character
==
HttpRuleParser
.
CR
)
||
(
character
==
HttpRuleParser
.
LF
))
{
return
true
;
}
}
return
false
;
}
#
region
IDisposable
Members
protected
virtual
void
Dispose
(
bool
disposing
)
...
...
src/libraries/System.Net.Mail/src/System/Net/Mail/MailBnfHelper.cs
浏览文件 @
11d8e264
...
...
@@ -379,23 +379,12 @@ private static bool CheckForUnicode(char ch, bool allowUnicode)
return
true
;
}
internal
static
bool
IsAllowedWhiteSpace
(
char
c
)
{
internal
static
bool
IsAllowedWhiteSpace
(
char
c
)
=>
// all allowed whitespace characters
return
c
==
Tab
||
c
==
Space
||
c
==
CR
||
c
==
LF
;
}
c
==
Tab
||
c
==
Space
||
c
==
CR
||
c
==
LF
;
internal
static
bool
HasCROrLF
(
string
data
)
{
for
(
int
i
=
0
;
i
<
data
.
Length
;
i
++)
{
if
(
data
[
i
]
==
'\r'
||
data
[
i
]
==
'\n'
)
{
return
true
;
}
}
return
false
;
}
internal
static
bool
HasCROrLF
(
string
data
)
=>
data
.
AsSpan
().
IndexOfAny
(
CR
,
LF
)
>=
0
;
// Is there a FWS ("\r\n " or "\r\n\t") starting at the given index?
internal
static
bool
IsFWSAt
(
string
data
,
int
index
)
...
...
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/TypeNameBuilder.cs
浏览文件 @
11d8e264
...
...
@@ -246,11 +246,14 @@ private void SetUseAngleBracketsForGenerics(bool value)
private
void
Append
(
string
pStr
)
{
foreach
(
char
c
in
pStr
)
int
i
=
pStr
.
IndexOf
(
'\0'
);
if
(
i
<
0
)
{
if
(
c
==
'\0'
)
break
;
_str
.
Append
(
c
);
_str
.
Append
(
pStr
);
}
else
if
(
i
>
0
)
{
_str
.
Append
(
pStr
.
AsSpan
(
0
,
i
));
}
}
...
...
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.cs
浏览文件 @
11d8e264
...
...
@@ -9,23 +9,15 @@ public sealed partial class TimeZoneInfo
{
private
static
unsafe
bool
TryConvertIanaIdToWindowsId
(
string
ianaId
,
bool
allocate
,
out
string
?
windowsId
)
{
if
(
GlobalizationMode
.
Invariant
||
GlobalizationMode
.
UseNls
||
ianaId
is
null
)
if
(
GlobalizationMode
.
Invariant
||
GlobalizationMode
.
UseNls
||
ianaId
is
null
||
ianaId
.
AsSpan
().
IndexOfAny
(
'\\'
,
'\n'
,
'\r'
)
>=
0
)
// ICU uses these characters as a separator
{
windowsId
=
null
;
return
false
;
}
foreach
(
char
c
in
ianaId
)
{
// ICU uses some characters as a separator and trim the id at that character.
// while we should fail if the Id contained one of these characters.
if
(
c
==
'\\'
||
c
==
'\n'
||
c
==
'\r'
)
{
windowsId
=
null
;
return
false
;
}
}
char
*
buffer
=
stackalloc
char
[
100
];
int
length
=
Interop
.
Globalization
.
IanaIdToWindowsId
(
ianaId
,
buffer
,
100
);
if
(
length
>
0
)
...
...
@@ -54,15 +46,10 @@ private static unsafe bool TryConvertWindowsIdToIanaId(string windowsId, string?
return
true
;
}
foreach
(
char
c
in
windowsId
)
if
(
windowsId
.
AsSpan
().
IndexOfAny
(
'\\'
,
'\n'
,
'\r'
)
>=
0
)
// ICU uses these characters as a separator
{
// ICU uses some characters as a separator and trim the id at that character.
// while we should fail if the Id contained one of these characters.
if
(
c
==
'\\'
||
c
==
'\n'
||
c
==
'\r'
)
{
ianaId
=
null
;
return
false
;
}
ianaId
=
null
;
return
false
;
}
// regionPtr will point at the region name encoded as ASCII.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录