Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
c65864cd
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c65864cd
编写于
5月 29, 2020
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prefer no allocation `start/end_with?` over `String#[] ==`
上级
97c3a560
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
22 addition
and
18 deletion
+22
-18
actionview/lib/action_view/dependency_tracker.rb
actionview/lib/action_view/dependency_tracker.rb
+1
-1
actionview/lib/action_view/renderer/abstract_renderer.rb
actionview/lib/action_view/renderer/abstract_renderer.rb
+1
-1
actionview/lib/action_view/template.rb
actionview/lib/action_view/template.rb
+1
-1
activemodel/README.rdoc
activemodel/README.rdoc
+1
-1
activemodel/lib/active_model/validations.rb
activemodel/lib/active_model/validations.rb
+2
-2
activerecord/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb
...record/connection_adapters/postgresql/oid/legacy_point.rb
+1
-1
activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb
...active_record/connection_adapters/postgresql/oid/point.rb
+1
-1
activerecord/lib/active_record/connection_adapters/postgresql/oid/range.rb
...active_record/connection_adapters/postgresql/oid/range.rb
+5
-5
activesupport/lib/active_support/array_inquirer.rb
activesupport/lib/active_support/array_inquirer.rb
+4
-2
activesupport/lib/active_support/string_inquirer.rb
activesupport/lib/active_support/string_inquirer.rb
+4
-2
railties/lib/rails/source_annotation_extractor.rb
railties/lib/rails/source_annotation_extractor.rb
+1
-1
未找到文件。
actionview/lib/action_view/dependency_tracker.rb
浏览文件 @
c65864cd
...
...
@@ -170,7 +170,7 @@ def resolve_directories(wildcard_dependencies)
def
explicit_dependencies
dependencies
=
source
.
scan
(
EXPLICIT_DEPENDENCY
).
flatten
.
uniq
wildcards
,
explicits
=
dependencies
.
partition
{
|
dependency
|
dependency
[
-
1
]
==
"*"
}
wildcards
,
explicits
=
dependencies
.
partition
{
|
dependency
|
dependency
.
end_with?
(
"*"
)
}
(
explicits
+
resolve_directories
(
wildcards
)).
uniq
end
...
...
actionview/lib/action_view/renderer/abstract_renderer.rb
浏览文件 @
c65864cd
...
...
@@ -46,7 +46,7 @@ def local_variable(path)
as
.
to_sym
else
begin
base
=
path
[
-
1
]
==
"/"
?
""
:
File
.
basename
(
path
)
base
=
path
.
end_with?
(
"/"
)
?
""
:
File
.
basename
(
path
)
raise_invalid_identifier
(
path
)
unless
base
=~
/\A_?(.*?)(?:\.\w+)*\z/
$1
.
to_sym
end
...
...
actionview/lib/action_view/template.rb
浏览文件 @
c65864cd
...
...
@@ -138,7 +138,7 @@ def initialize(source, identifier, handler, format: nil, variant: nil, locals: n
@virtual_path
=
virtual_path
@variable
=
if
@virtual_path
base
=
@virtual_path
[
-
1
]
==
"/"
?
""
:
::
File
.
basename
(
@virtual_path
)
base
=
@virtual_path
.
end_with?
(
"/"
)
?
""
:
::
File
.
basename
(
@virtual_path
)
base
=~
/\A_?(.*?)(?:\.\w+)*\z/
$1
.
to_sym
end
...
...
activemodel/README.rdoc
浏览文件 @
c65864cd
...
...
@@ -200,7 +200,7 @@ behavior out of the box:
attr_accessor :first_name, :last_name
validates_each :first_name, :last_name do |record, attr, value|
record.errors.add attr,
'starts with z.' if value.to_s[0] == ?z
record.errors.add attr,
"starts with z." if value.start_with?("z")
end
end
...
...
activemodel/lib/active_model/validations.rb
浏览文件 @
c65864cd
...
...
@@ -15,7 +15,7 @@ module ActiveModel
# attr_accessor :first_name, :last_name
#
# validates_each :first_name, :last_name do |record, attr, value|
# record.errors.add attr,
'starts with z.' if value.to_s[0] == ?z
# record.errors.add attr,
"starts with z." if value.start_with?("z")
# end
# end
#
...
...
@@ -61,7 +61,7 @@ module ClassMethods
# attr_accessor :first_name, :last_name
#
# validates_each :first_name, :last_name, allow_blank: true do |record, attr, value|
# record.errors.add attr,
'starts with z.' if value.to_s[0] == ?z
# record.errors.add attr,
"starts with z." if value.start_with?("z")
# end
# end
#
...
...
activerecord/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb
浏览文件 @
c65864cd
...
...
@@ -14,7 +14,7 @@ def type
def
cast
(
value
)
case
value
when
::
String
if
value
[
0
]
==
"("
&&
value
[
-
1
]
==
")"
if
value
.
start_with?
(
"("
)
&&
value
.
end_with?
(
")"
)
value
=
value
[
1
...-
1
]
end
cast
(
value
.
split
(
","
))
...
...
activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb
浏览文件 @
c65864cd
...
...
@@ -18,7 +18,7 @@ def cast(value)
when
::
String
return
if
value
.
blank?
if
value
[
0
]
==
"("
&&
value
[
-
1
]
==
")"
if
value
.
start_with?
(
"("
)
&&
value
.
end_with?
(
")"
)
value
=
value
[
1
...-
1
]
end
x
,
y
=
value
.
split
(
","
)
...
...
activerecord/lib/active_record/connection_adapters/postgresql/oid/range.rb
浏览文件 @
c65864cd
...
...
@@ -67,12 +67,12 @@ def type_cast_single_for_database(value)
end
def
extract_bounds
(
value
)
from
,
to
=
value
[
1
..-
2
].
split
(
","
)
from
,
to
=
value
[
1
..-
2
].
split
(
","
,
2
)
{
from:
(
value
[
1
]
==
",
"
||
from
==
"-infinity"
)
?
infinity
(
negative:
true
)
:
from
,
to:
(
value
[
-
2
]
==
",
"
||
to
==
"infinity"
)
?
infinity
:
to
,
exclude_start:
(
value
[
0
]
==
"("
),
exclude_end:
(
value
[
-
1
]
==
")"
)
from:
(
from
==
"
"
||
from
==
"-infinity"
)
?
infinity
(
negative:
true
)
:
from
,
to:
(
to
==
"
"
||
to
==
"infinity"
)
?
infinity
:
to
,
exclude_start:
value
.
start_with?
(
"("
),
exclude_end:
value
.
end_with?
(
")"
)
}
end
...
...
activesupport/lib/active_support/array_inquirer.rb
浏览文件 @
c65864cd
# frozen_string_literal: true
require
"active_support/core_ext/symbol/starts_ends_with"
module
ActiveSupport
# Wrapping an array in an +ArrayInquirer+ gives a friendlier way to check
# its string-like contents:
...
...
@@ -34,11 +36,11 @@ def any?(*candidates)
private
def
respond_to_missing?
(
name
,
include_private
=
false
)
(
name
[
-
1
]
==
"?"
)
||
super
name
.
end_with?
(
"?"
)
||
super
end
def
method_missing
(
name
,
*
args
)
if
name
[
-
1
]
==
"?"
if
name
.
end_with?
(
"?"
)
any?
(
name
[
0
..-
2
])
else
super
...
...
activesupport/lib/active_support/string_inquirer.rb
浏览文件 @
c65864cd
# frozen_string_literal: true
require
"active_support/core_ext/symbol/starts_ends_with"
module
ActiveSupport
# Wrapping a string in this class gives you a prettier way to test
# for equality. The value returned by <tt>Rails.env</tt> is wrapped
...
...
@@ -19,11 +21,11 @@ module ActiveSupport
class
StringInquirer
<
String
private
def
respond_to_missing?
(
method_name
,
include_private
=
false
)
(
method_name
[
-
1
]
==
"?"
)
||
super
method_name
.
end_with?
(
"?"
)
||
super
end
def
method_missing
(
method_name
,
*
arguments
)
if
method_name
[
-
1
]
==
"?"
if
method_name
.
end_with?
(
"?"
)
self
==
method_name
[
0
..-
2
]
else
super
...
...
railties/lib/rails/source_annotation_extractor.rb
浏览文件 @
c65864cd
...
...
@@ -109,7 +109,7 @@ def find_in(dir)
results
=
{}
Dir
.
glob
(
"
#{
dir
}
/*"
)
do
|
item
|
next
if
File
.
basename
(
item
)
[
0
]
==
?.
next
if
File
.
basename
(
item
)
.
start_with?
(
"."
)
if
File
.
directory?
(
item
)
results
.
update
(
find_in
(
item
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录