Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
f846c970
R
runtime
项目概览
dotNET Platform
/
runtime
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
f846c970
编写于
3月 23, 2022
作者:
S
Stephen Toub
提交者:
GitHub
3月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid bool[] allocation in MemberInfoCache.PopulateProperties (#66912)
上级
103fb847
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
8 deletion
+19
-8
src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
.../System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
+19
-8
未找到文件。
src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
浏览文件 @
f846c970
...
...
@@ -1252,20 +1252,30 @@ private RuntimePropertyInfo[] PopulateProperties(Filter filter)
Dictionary
<
string
,
List
<
RuntimePropertyInfo
>>?
csPropertyInfos
=
filter
.
CaseSensitive
()
?
null
:
new
Dictionary
<
string
,
List
<
RuntimePropertyInfo
>>();
// All elements automatically initialized to false.
bool
[]
usedSlots
=
new
bool
[
RuntimeTypeHandle
.
GetNumVirtuals
(
declaringType
)];
// All elements initialized to false.
int
numVirtuals
=
RuntimeTypeHandle
.
GetNumVirtuals
(
declaringType
);
Span
<
bool
>
usedSlots
=
stackalloc
bool
[
0
];
if
(
numVirtuals
<=
128
)
// arbitrary stack limit
{
usedSlots
=
stackalloc
bool
[
numVirtuals
];
usedSlots
.
Clear
();
}
else
{
usedSlots
=
new
bool
[
numVirtuals
];
}
// Populate associates off of the class hierarchy
do
{
PopulateProperties
(
filter
,
declaringType
,
csPropertyInfos
,
usedSlots
,
ref
list
);
PopulateProperties
(
filter
,
declaringType
,
csPropertyInfos
,
usedSlots
,
isInterface
:
false
,
ref
list
);
declaringType
=
RuntimeTypeHandle
.
GetBaseType
(
declaringType
);
}
while
(
declaringType
!=
null
);
}
else
{
// Populate associates for this interface
PopulateProperties
(
filter
,
declaringType
,
null
,
null
,
ref
list
);
PopulateProperties
(
filter
,
declaringType
,
null
,
default
,
isInterface
:
true
,
ref
list
);
}
return
list
.
ToArray
();
...
...
@@ -1275,7 +1285,8 @@ private RuntimePropertyInfo[] PopulateProperties(Filter filter)
Filter
filter
,
RuntimeType
declaringType
,
Dictionary
<
string
,
List
<
RuntimePropertyInfo
>>?
csPropertyInfos
,
bool
[]?
usedSlots
,
Span
<
bool
>
usedSlots
,
bool
isInterface
,
ref
ListBuilder
<
RuntimePropertyInfo
>
list
)
{
int
tkDeclaringType
=
RuntimeTypeHandle
.
GetToken
(
declaringType
);
...
...
@@ -1290,8 +1301,8 @@ private RuntimePropertyInfo[] PopulateProperties(Filter filter)
int
numVirtuals
=
RuntimeTypeHandle
.
GetNumVirtuals
(
declaringType
);
Debug
.
Assert
((
declaringType
.
IsInterface
&&
usedSlots
==
null
&&
csPropertyInfos
==
null
)
||
(!
declaringType
.
IsInterface
&&
usedSlots
!=
null
&&
usedSlots
.
Length
>=
numVirtuals
));
Debug
.
Assert
((
declaringType
.
IsInterface
&&
isInterface
&&
csPropertyInfos
==
null
)
||
(!
declaringType
.
IsInterface
&&
!
isInterface
&&
usedSlots
.
Length
>=
numVirtuals
));
for
(
int
i
=
0
;
i
<
tkProperties
.
Length
;
i
++)
{
...
...
@@ -1313,7 +1324,7 @@ private RuntimePropertyInfo[] PopulateProperties(Filter filter)
tkProperty
,
declaringType
,
m_runtimeTypeCache
,
out
bool
isPrivate
);
// If this is a class, not an interface
if
(
usedSlots
!=
null
)
if
(
!
isInterface
)
{
#
region
Remove
Privates
if
(
declaringType
!=
ReflectedType
&&
isPrivate
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录