Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
Brakeman
提交
60d0b814
B
Brakeman
项目概览
李少辉-开发者
/
Brakeman
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
Brakeman
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
60d0b814
编写于
12月 20, 2011
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cache hash value of Sexps
for faster lookups
上级
eadf8545
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
89 addition
and
18 deletion
+89
-18
lib/brakeman/util.rb
lib/brakeman/util.rb
+0
-17
lib/ruby_parser/ruby_parser_extras.rb
lib/ruby_parser/ruby_parser_extras.rb
+89
-1
未找到文件。
lib/brakeman/util.rb
浏览文件 @
60d0b814
...
...
@@ -187,20 +187,3 @@ module Brakeman::Util
exp
.
is_a?
Sexp
end
end
class
Sexp
alias
:old_init
:initialize
def
initialize
*
args
old_init
*
args
@original_line
=
nil
end
def
original_line
line
=
nil
if
line
@original_line
=
line
else
@original_line
end
end
end
lib/ruby_parser/ruby_parser_extras.rb
浏览文件 @
60d0b814
...
...
@@ -1052,7 +1052,7 @@ class Symbol
end
class
Sexp
attr_
writ
er
:paren
attr_
read
er
:paren
def
paren
@paren
||=
false
...
...
@@ -1069,6 +1069,94 @@ class Sexp
alias
:node_type
:sexp_type
alias
:values
:sexp_body
# TODO: retire
alias
:old_init
:initialize
alias
:old_push
:<<
alias
:old_line
:line
alias
:old_line_set
:line
=
alias
:old_file_set
:file
=
alias
:old_comments_set
:comments
=
alias
:old_compact
:compact
alias
:old_fara
:find_and_replace_all
alias
:old_find_node
:find_node
def
initialize
*
args
old_init
*
args
@original_line
=
nil
@my_hash_value
=
nil
end
def
original_line
line
=
nil
if
line
@my_hash_value
=
nil
@original_line
=
line
else
@original_line
end
end
def
hash
#There still seems to be some instances in which the hash of the
#Sexp changes, but I have not found what method call is doing it.
#Of course, Sexp is subclasses from Array, so who knows what might
#be going on.
@my_hash_value
||=
super
end
def
line
*
args
@my_hash_value
=
nil
old_line
*
args
end
def
line
=
*
args
@my_hash_value
=
nil
old_line_set
*
args
end
def
file
=
*
args
@my_hash_value
=
nil
old_file_set
*
args
end
def
compact
@my_hash_value
=
nil
old_compact
*
args
end
def
find_and_replace_all
*
args
@my_hash_value
=
nil
old_fara
*
args
end
def
find_node
*
args
@my_hash_value
=
nil
old_find_node
*
args
end
def
paren
=
arg
@my_hash_value
=
nil
@paren
=
arg
end
def
comments
=
*
args
@my_hash_value
=
nil
old_comments_set
*
args
end
end
#Invalidate hash cache if the Sexp changes
[
:[]=
,
:clear
,
:collect!
,
:compact!
,
:concat
,
:delete
,
:delete_at
,
:delete_if
,
:drop
,
:drop_while
,
:fill
,
:flatten!
,
:replace
,
:insert
,
:keep_if
,
:map!
,
:pop
,
:push
,
:reject!
,
:replace
,
:reverse!
,
:rotate!
,
:select!
,
:shift
,
:shuffle!
,
:slice!
,
:sort!
,
:sort_by!
,
:transpose
,
:uniq!
,
:unshift
].
each
do
|
method
|
Sexp
.
class_eval
<<-
RUBY
def
#{
method
}
*args
@my_hash_value = nil
super
end
RUBY
end
# END HACK
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录