Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
6d96c913
F
fsharp
项目概览
dotNET Platform
/
fsharp
12 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6d96c913
编写于
11月 01, 2019
作者:
T
TIHan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use cache value if available early in a let binding. Stops from having to traverse entire expr.
上级
edcebae9
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
17 addition
and
6 deletion
+17
-6
src/fsharp/TastOps.fs
src/fsharp/TastOps.fs
+13
-6
src/fsharp/lib.fs
src/fsharp/lib.fs
+4
-0
未找到文件。
src/fsharp/TastOps.fs
浏览文件 @
6d96c913
...
@@ -4388,6 +4388,10 @@ let bindLhs opts (bind: Binding) fvs = boundLocalVal opts bind.Var fvs
...
@@ -4388,6 +4388,10 @@ let bindLhs opts (bind: Binding) fvs = boundLocalVal opts bind.Var fvs
let
freeVarsCacheCompute
opts
cache
f
=
if
opts
.
canCache
then
cached
cache
f
else
f
()
let
freeVarsCacheCompute
opts
cache
f
=
if
opts
.
canCache
then
cached
cache
f
else
f
()
let
tryGetFreeVarsCacheValue
opts
cache
=
if
opts
.
canCache
then
tryGetCacheValue
cache
else
ValueNone
let
rec
accBindRhs
opts
(
TBind
(_,
repr
,
_))
acc
=
accFreeInExpr
opts
repr
acc
let
rec
accBindRhs
opts
(
TBind
(_,
repr
,
_))
acc
=
accFreeInExpr
opts
repr
acc
and
accFreeInSwitchCases
opts
csl
dflt
(
acc
:
FreeVars
)
=
and
accFreeInSwitchCases
opts
csl
dflt
(
acc
:
FreeVars
)
=
...
@@ -4486,12 +4490,15 @@ and accFreeInExprLinear (opts: FreeVarOptions) x acc contf =
...
@@ -4486,12 +4490,15 @@ and accFreeInExprLinear (opts: FreeVarOptions) x acc contf =
// for nested let-bindings, we need to continue after the whole let-binding is processed
// for nested let-bindings, we need to continue after the whole let-binding is processed
match
x
with
match
x
with
|
Expr
.
Let
(
bind
,
e
,
_,
cache
)
->
|
Expr
.
Let
(
bind
,
e
,
_,
cache
)
->
let
contf
=
contf
<<
(
fun
free
->
match
tryGetFreeVarsCacheValue
opts
cache
with
unionFreeVars
(
freeVarsCacheCompute
opts
cache
(
fun
()
->
bindLhs
opts
bind
(
accBindRhs
opts
bind
free
)))
acc
)
|
ValueSome
free
->
contf
(
unionFreeVars
free
acc
)
accFreeInExprLinear
opts
e
emptyFreeVars
contf
|
_
->
accFreeInExprLinear
opts
e
emptyFreeVars
(
contf
<<
(
fun
free
->
unionFreeVars
(
freeVarsCacheCompute
opts
cache
(
fun
()
->
bindLhs
opts
bind
(
accBindRhs
opts
bind
free
)))
acc
))
|
_
->
|
_
->
// No longer linear expr
// No longer linear expr
accFreeInExpr
opts
x
acc
|>
contf
contf
(
accFreeInExpr
opts
x
acc
)
and
accFreeInExprNonLinear
opts
x
acc
=
and
accFreeInExprNonLinear
opts
x
acc
=
match
x
with
match
x
with
...
...
src/fsharp/lib.fs
浏览文件 @
6d96c913
...
@@ -394,6 +394,10 @@ let inline cacheOptRef cache f =
...
@@ -394,6 +394,10 @@ let inline cacheOptRef cache f =
cache
:=
Some
res
cache
:=
Some
res
res
res
let
inline
tryGetCacheValue
cache
=
match
box
cache
.
cacheVal
with
|
null
->
ValueNone
|
_
->
ValueSome
cache
.
cacheVal
#
if
DUMPER
#
if
DUMPER
type
Dumper
(
x
:
obj
)
=
type
Dumper
(
x
:
obj
)
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录