Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
756507c3
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
756507c3
编写于
12月 10, 2015
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix issue in our binary search for a fuzzy name.
上级
1aabbde2
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
10 addition
and
11 deletion
+10
-11
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
...es/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
+10
-11
未找到文件。
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
浏览文件 @
756507c3
...
...
@@ -16,7 +16,7 @@ internal partial class SymbolTreeInfo
/// <summary>
/// The list of nodes that represent symbols. The primary key into the sorting of this list is the name.
/// They are sorted case-insensitively with the <see cref="s_
nodeSort
Comparer" />. Finding case-sensitive
/// They are sorted case-insensitively with the <see cref="s_
total
Comparer" />. Finding case-sensitive
/// matches can be found by binary searching for something that matches insensitively, and then searching
/// around that equivalence class for one that matches.
/// </summary>
...
...
@@ -27,6 +27,8 @@ internal partial class SymbolTreeInfo
/// </summary>
private
readonly
BKTree
_bkTree
;
private
static
readonly
StringComparer
s_caseInsensitiveComparer
=
CaseInsensitiveComparison
.
Comparer
;
// We first sort in a case insensitive manner. But, within items that match insensitively,
// we then sort in a case sensitive manner. This helps for searching as we'll walk all
// the items of a specific casing at once. This way features can cache values for that
...
...
@@ -35,16 +37,14 @@ internal partial class SymbolTreeInfo
// they're searching for. However, with this sort of comparison we now get
// "prop, prop, Prop, Prop". Features can take advantage of that by caching their previous
// result and reusing it when they see they're getting the same string again.
private
static
readonly
Comparison
<
string
>
s_
nodeSort
Comparer
=
(
s1
,
s2
)
=>
private
static
readonly
Comparison
<
string
>
s_
total
Comparer
=
(
s1
,
s2
)
=>
{
var
diff
=
CaseInsensitiveComparison
.
Comparer
.
Compare
(
s1
,
s2
);
var
diff
=
s_caseInsensitive
Comparer
.
Compare
(
s1
,
s2
);
return
diff
!=
0
?
diff
:
StringComparer
.
Ordinal
.
Compare
(
s1
,
s2
);
};
private
static
readonly
StringComparer
s_nodeEquals
=
CaseInsensitiveComparison
.
Comparer
;
private
SymbolTreeInfo
(
VersionStamp
version
,
IReadOnlyList
<
Node
>
orderedNodes
,
BKTree
bkTree
)
{
_version
=
version
;
...
...
@@ -132,10 +132,9 @@ private IEnumerable<int> FindNodes(string name, StringComparer comparer)
}
int
position
=
startingPosition
;
while
(
position
>
0
&&
s_
nodeEquals
.
Equals
(
_nodes
[
position
-
1
].
Name
,
name
))
while
(
position
>
0
&&
s_
caseInsensitiveComparer
.
Equals
(
_nodes
[
position
-
1
].
Name
,
name
))
{
position
--;
if
(
comparer
.
Equals
(
_nodes
[
position
].
Name
,
name
))
{
yield
return
position
;
...
...
@@ -143,7 +142,7 @@ private IEnumerable<int> FindNodes(string name, StringComparer comparer)
}
position
=
startingPosition
;
while
(
position
+
1
<
_nodes
.
Count
&&
s_
nodeEquals
.
Equals
(
_nodes
[
position
+
1
].
Name
,
name
))
while
(
position
+
1
<
_nodes
.
Count
&&
s_
caseInsensitiveComparer
.
Equals
(
_nodes
[
position
+
1
].
Name
,
name
))
{
position
++;
if
(
comparer
.
Equals
(
_nodes
[
position
].
Name
,
name
))
...
...
@@ -155,7 +154,7 @@ private IEnumerable<int> FindNodes(string name, StringComparer comparer)
}
/// <summary>
/// Searches for a name in the ordered list that matches per the <see cref="s_
nodeSort
Comparer" />.
/// Searches for a name in the ordered list that matches per the <see cref="s_
caseInsensitive
Comparer" />.
/// </summary>
private
int
BinarySearch
(
string
name
)
{
...
...
@@ -166,7 +165,7 @@ private int BinarySearch(string name)
{
int
mid
=
min
+
((
max
-
min
)
>>
1
);
var
comparison
=
s_
nodeSortComparer
(
_nodes
[
mid
].
Name
,
name
);
var
comparison
=
s_
caseInsensitiveComparer
.
Compare
(
_nodes
[
mid
].
Name
,
name
);
if
(
comparison
<
0
)
{
min
=
mid
+
1
;
...
...
@@ -280,7 +279,7 @@ private static Node[] SortNodes(List<Node> nodes)
private
static
int
CompareNodes
(
Node
x
,
Node
y
,
IReadOnlyList
<
Node
>
nodeList
)
{
var
comp
=
s_
nodeSort
Comparer
(
x
.
Name
,
y
.
Name
);
var
comp
=
s_
total
Comparer
(
x
.
Name
,
y
.
Name
);
if
(
comp
==
0
)
{
if
(
x
.
ParentIndex
!=
y
.
ParentIndex
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录