提交 a94c2e1f 编写于 作者: J Jean Boussier

Use == 0 instead of .zero? in #try

The perf gain is relatively minor but consistent:

```
Calculating -------------------------------------
             0.zero?   137.091k i/100ms
             1.zero?   137.350k i/100ms
              0 == 0   142.207k i/100ms
              1 == 0   144.724k i/100ms
-------------------------------------------------
             0.zero?      8.893M (± 6.5%) i/s -     44.280M
             1.zero?      8.751M (± 6.4%) i/s -     43.677M
              0 == 0     10.033M (± 7.0%) i/s -     49.915M
              1 == 0      9.814M (± 8.0%) i/s -     48.772M
```

And try! is quite a big hotspot for us so every little gain is appreciable.
上级 8d7b883f
......@@ -8,7 +8,7 @@ def try(*a, &b)
def try!(*a, &b)
if a.empty? && block_given?
if b.arity.zero?
if b.arity == 0
instance_eval(&b)
else
yield self
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册