Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
88f2b8aa
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,发现更多精彩内容 >>
提交
88f2b8aa
编写于
9月 14, 2015
作者:
H
Heejae Chang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed #5203 by caching boxed object only once and re-use them
上级
0fd8c380
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
11 deletion
+50
-11
src/VisualStudio/Core/Def/Implementation/TableDataSource/ValueTypeCache.cs
...Core/Def/Implementation/TableDataSource/ValueTypeCache.cs
+37
-0
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
...isualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
+4
-4
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseTodoListTable.cs
...entation/TableDataSource/VisualStudioBaseTodoListTable.cs
+3
-3
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs
...e/VisualStudioDiagnosticListTable.BuildTableDataSource.cs
+5
-4
src/VisualStudio/Core/Def/ServicesVisualStudio.csproj
src/VisualStudio/Core/Def/ServicesVisualStudio.csproj
+1
-0
未找到文件。
src/VisualStudio/Core/Def/Implementation/TableDataSource/ValueTypeCache.cs
0 → 100644
浏览文件 @
88f2b8aa
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
using
System.Collections.Concurrent
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
internal
static
class
ValueTypeCache
{
/// <summary>
/// Re-use already boxed object for value type.
/// this cache never release cached object. must be used only with fixed set of valut types. or
/// something that grows very slowly like Guid for projects.
/// </summary>
public
static
object
GetOrCreate
<
T
>(
T
value
)
where
T
:
struct
{
// let compiler creates a cache for each value type.
return
Cache
<
T
>.
Instance
.
GetOrCreate
(
value
);
}
private
class
Cache
<
T
>
where
T
:
struct
{
public
static
readonly
Cache
<
T
>
Instance
=
new
Cache
<
T
>();
private
static
readonly
Func
<
T
,
object
>
_boxer
=
v
=>
(
object
)
v
;
// this will be never released, must be used only for fixed size set
private
readonly
ConcurrentDictionary
<
T
,
object
>
_map
=
new
ConcurrentDictionary
<
T
,
object
>(
concurrencyLevel
:
2
,
capacity
:
5
);
public
object
GetOrCreate
(
T
value
)
{
return
_map
.
GetOrAdd
(
value
,
_boxer
);
}
}
}
}
\ No newline at end of file
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
浏览文件 @
88f2b8aa
...
...
@@ -257,10 +257,10 @@ public override bool TryGetValue(int index, string columnName, out object conten
switch
(
columnName
)
{
case
StandardTableKeyNames
.
ErrorRank
:
content
=
GetErrorRank
(
data
);
content
=
ValueTypeCache
.
GetOrCreate
(
GetErrorRank
(
data
)
);
return
true
;
case
StandardTableKeyNames
.
ErrorSeverity
:
content
=
GetErrorCategory
(
data
.
Severity
);
content
=
ValueTypeCache
.
GetOrCreate
(
GetErrorCategory
(
data
.
Severity
)
);
return
true
;
case
StandardTableKeyNames
.
ErrorCode
:
content
=
data
.
Id
;
...
...
@@ -275,7 +275,7 @@ public override bool TryGetValue(int index, string columnName, out object conten
content
=
data
.
Category
;
return
true
;
case
StandardTableKeyNames
.
ErrorSource
:
content
=
GetErrorSource
(
_source
.
BuildTool
);
content
=
ValueTypeCache
.
GetOrCreate
(
GetErrorSource
(
_source
.
BuildTool
)
);
return
true
;
case
StandardTableKeyNames
.
BuildTool
:
content
=
GetBuildTool
(
_source
.
BuildTool
);
...
...
@@ -299,7 +299,7 @@ public override bool TryGetValue(int index, string columnName, out object conten
content
=
item
.
ProjectNames
;
return
((
string
[])
content
).
Length
>
0
;
case
StandardTableKeyNames
.
ProjectGuid
:
content
=
item
.
ProjectGuid
;
content
=
ValueTypeCache
.
GetOrCreate
(
item
.
ProjectGuid
)
;
return
(
Guid
)
content
!=
Guid
.
Empty
;
case
ProjectGuids
:
content
=
item
.
ProjectGuids
;
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseTodoListTable.cs
浏览文件 @
88f2b8aa
...
...
@@ -235,7 +235,7 @@ public override bool TryGetValue(int index, string columnName, out object conten
switch
(
columnName
)
{
case
StandardTableKeyNames
.
Priority
:
content
=
(
VSTASKPRIORITY
)
data
.
Priority
;
content
=
ValueTypeCache
.
GetOrCreate
((
VSTASKPRIORITY
)
data
.
Priority
)
;
return
true
;
case
StandardTableKeyNames
.
Text
:
content
=
data
.
Message
;
...
...
@@ -250,7 +250,7 @@ public override bool TryGetValue(int index, string columnName, out object conten
content
=
GetLineColumn
(
data
).
Character
;
return
true
;
case
StandardTableKeyNames
.
TaskCategory
:
content
=
V
STASKCATEGORY
.
CAT_COMMENTS
;
content
=
V
alueTypeCache
.
GetOrCreate
(
VSTASKCATEGORY
.
CAT_COMMENTS
)
;
return
true
;
case
StandardTableKeyNames
.
ProjectName
:
content
=
item
.
ProjectName
;
...
...
@@ -259,7 +259,7 @@ public override bool TryGetValue(int index, string columnName, out object conten
content
=
item
.
ProjectNames
;
return
((
string
[])
content
).
Length
>
0
;
case
StandardTableKeyNames
.
ProjectGuid
:
content
=
item
.
ProjectGuid
;
content
=
ValueTypeCache
.
GetOrCreate
(
item
.
ProjectGuid
)
;
return
(
Guid
)
content
!=
Guid
.
Empty
;
case
ProjectGuids
:
content
=
item
.
ProjectGuids
;
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs
浏览文件 @
88f2b8aa
...
...
@@ -180,10 +180,11 @@ public override bool TryGetValue(int index, string columnName, out object conten
switch
(
columnName
)
{
case
StandardTableKeyNames
.
ErrorRank
:
content
=
WellKnownDiagnosticTags
.
Build
;
// build error gets highest rank
content
=
ValueTypeCache
.
GetOrCreate
(
ErrorRank
.
Lexical
);
return
true
;
case
StandardTableKeyNames
.
ErrorSeverity
:
content
=
GetErrorCategory
(
data
.
Severity
);
content
=
ValueTypeCache
.
GetOrCreate
(
GetErrorCategory
(
data
.
Severity
)
);
return
true
;
case
StandardTableKeyNames
.
ErrorCode
:
content
=
data
.
Id
;
...
...
@@ -198,7 +199,7 @@ public override bool TryGetValue(int index, string columnName, out object conten
content
=
data
.
Category
;
return
true
;
case
StandardTableKeyNames
.
ErrorSource
:
content
=
ErrorSource
.
Build
;
content
=
ValueTypeCache
.
GetOrCreate
(
ErrorSource
.
Build
)
;
return
true
;
case
StandardTableKeyNames
.
BuildTool
:
content
=
_source
.
BuildTool
;
...
...
@@ -222,7 +223,7 @@ public override bool TryGetValue(int index, string columnName, out object conten
content
=
item
.
ProjectNames
;
return
((
string
[])
content
).
Length
>
0
;
case
StandardTableKeyNames
.
ProjectGuid
:
content
=
item
.
ProjectGuid
;
content
=
ValueTypeCache
.
GetOrCreate
(
item
.
ProjectGuid
)
;
return
(
Guid
)
content
!=
Guid
.
Empty
;
case
ProjectGuids
:
content
=
item
.
ProjectGuids
;
...
...
src/VisualStudio/Core/Def/ServicesVisualStudio.csproj
浏览文件 @
88f2b8aa
...
...
@@ -78,6 +78,7 @@
<Compile
Include=
"Implementation\ProjectInfo\DefaultProjectInfoServiceFactory.cs"
/>
<Compile
Include=
"Implementation\TableDataSource\MiscTodoListTableControlEventProcessorProvider.cs"
/>
<Compile
Include=
"Implementation\TableDataSource\UriNavigator.cs"
/>
<Compile
Include=
"Implementation\TableDataSource\ValueTypeCache.cs"
/>
<Compile
Include=
"Implementation\TableDataSource\VisualStudioBaseDiagnosticListTable.LiveTableDataSource.cs"
/>
<Compile
Include=
"Implementation\TableDataSource\VisualStudioDiagnosticListTable.BuildTableDataSource.cs"
/>
<Compile
Include=
"Implementation\TableDataSource\VisualStudioDiagnosticListTable.cs"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录