Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
342e4cd6
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,发现更多精彩内容 >>
未验证
提交
342e4cd6
编写于
6月 14, 2021
作者:
H
Huo Yaoyuan
提交者:
GitHub
6月 14, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup BitVector32 (#54097)
* Cleanup BitVector32 * Cleanup Section.ToString
上级
4c0d2f01
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
78 deletion
+12
-78
src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/BitVector32.cs
...ialized/src/System/Collections/Specialized/BitVector32.cs
+12
-78
未找到文件。
src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/BitVector32.cs
浏览文件 @
342e4cd6
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using
System.Diagnostics
;
using
System.Text
;
using
System.Diagnostics.CodeAnalysis
;
using
System.Numerics
;
namespace
System.Collections.Specialized
{
...
...
@@ -93,18 +92,6 @@ public int Data
}
}
private
static
short
CountBitsSet
(
short
mask
)
{
// We assume that the bits are always right aligned, with no holes (i.e. always 00000111, never 00100011)
short
value
=
0
;
while
((
mask
&
0x1
)
!=
0
)
{
value
++;
mask
>>=
1
;
}
return
value
;
}
/// <devdoc>
/// <para> Creates the first mask in a series.</para>
/// </devdoc>
...
...
@@ -131,29 +118,6 @@ public static int CreateMask(int previous)
return
previous
<<
1
;
}
/// <devdoc>
/// Given a highValue, creates the mask
/// </devdoc>
private
static
short
CreateMaskFromHighValue
(
short
highValue
)
{
short
required
=
16
;
while
((
highValue
&
0x8000
)
==
0
)
{
required
--;
highValue
<<=
1
;
}
ushort
value
=
0
;
while
(
required
>
0
)
{
required
--;
value
<<=
1
;
value
|=
0x1
;
}
return
unchecked
((
short
)
value
);
}
/// <devdoc>
/// <para>Creates the first section in a series, with the specified maximum value.</para>
/// </devdoc>
...
...
@@ -177,28 +141,19 @@ private static Section CreateSectionHelper(short maxValue, short priorMask, shor
throw
new
ArgumentException
(
SR
.
Format
(
SR
.
Argument_InvalidValue_TooSmall
,
nameof
(
maxValue
),
1
),
nameof
(
maxValue
));
}
short
offset
=
(
short
)(
priorOffset
+
CountBitsSet
(
priorMask
));
short
offset
=
(
short
)(
priorOffset
+
BitOperations
.
PopCount
((
uint
)(
ushort
)
priorMask
));
if
(
offset
>=
32
)
{
throw
new
InvalidOperationException
(
SR
.
BitVectorFull
);
}
return
new
Section
(
CreateMaskFromHighValue
(
maxValue
),
offset
);
}
public
override
bool
Equals
([
NotNullWhen
(
true
)]
object
?
o
)
{
if
(!(
o
is
BitVector32
))
{
return
false
;
}
return
_data
==
((
BitVector32
)
o
).
_data
;
short
mask
=
(
short
)(
BitOperations
.
RoundUpToPowerOf2
((
uint
)(
ushort
)
maxValue
+
1
)
-
1
);
return
new
Section
(
mask
,
offset
);
}
public
override
int
GetHashCode
()
{
return
base
.
GetHashCode
();
}
public
override
bool
Equals
([
NotNullWhen
(
true
)]
object
?
o
)
=>
o
is
BitVector32
other
&&
_data
==
other
.
_data
;
public
override
int
GetHashCode
()
=>
_data
.
GetHashCode
();
public
static
string
ToString
(
BitVector32
value
)
{
...
...
@@ -238,29 +193,11 @@ internal Section(short mask, short offset)
_offset
=
offset
;
}
public
short
Mask
{
get
{
return
_mask
;
}
}
public
short
Mask
=>
_mask
;
public
short
Offset
{
get
{
return
_offset
;
}
}
public
short
Offset
=>
_offset
;
public
override
bool
Equals
([
NotNullWhen
(
true
)]
object
?
o
)
{
if
(
o
is
Section
)
return
Equals
((
Section
)
o
);
else
return
false
;
}
public
override
bool
Equals
([
NotNullWhen
(
true
)]
object
?
o
)
=>
o
is
Section
other
&&
Equals
(
other
);
public
bool
Equals
(
Section
obj
)
{
...
...
@@ -277,14 +214,11 @@ public bool Equals(Section obj)
return
!(
a
==
b
);
}
public
override
int
GetHashCode
()
{
return
base
.
GetHashCode
();
}
public
override
int
GetHashCode
()
=>
HashCode
.
Combine
(
_mask
,
_offset
);
public
static
string
ToString
(
Section
value
)
{
return
"Section{0x"
+
Convert
.
ToString
(
value
.
Mask
,
16
)
+
", 0x"
+
Convert
.
ToString
(
value
.
Offset
,
16
)
+
"
}"
;
return
$"Section
{{
0
x
{
value
.
Mask
:
x
},
0
x
{
value
.
Offset
:
x
}}
}
"
;
}
public
override
string
ToString
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录