diff options
| author | Geremia Taglialatela <[email protected]> | 2023-05-26 15:21:13 +0200 |
|---|---|---|
| committer | Geremia Taglialatela <[email protected]> | 2023-05-26 15:21:13 +0200 |
| commit | 2ed27823eaeb345e383343fb70dfa3f205f71ca1 (patch) | |
| tree | d0eb22ca642d70272fa4e5c4f30e30e7c9f38685 /examples/format_codes_example.md | |
| parent | 63a6edf1e191cf91fb80717ebae67c78af0d7db5 (diff) | |
| download | caxlsx-2ed27823eaeb345e383343fb70dfa3f205f71ca1.tar.gz caxlsx-2ed27823eaeb345e383343fb70dfa3f205f71ca1.zip | |
Fix Style/HashEachMethods offense
Replace `keys.each` with hash iteration
```rb
MY_HASH = {
first: '1',
second: '2',
third: '3'
}
%i[ips memory].each do |benchmark|
Benchmark.send(benchmark) do |x|
x.report("each_key") { MY_HASH.each_key { |k| MY_HASH[k] } }
x.report("keys.each") { MY_HASH.keys.each { |k| MY_HASH[k] } }
x.report("each") { MY_HASH.each { |k, v| v } }
x.compare!
end
end
```
```
IPS Comparison:
each: 4283031.6 i/s
each_key: 3683407.4 i/s - 1.16x (± 0.00) slower
keys.each: 3387425.1 i/s - 1.26x (± 0.00) slower
Memory Comparison:
each_key: 0 allocated
each: 0 allocated - same
keys.each: 40 allocated - Infx more
```
Diffstat (limited to 'examples/format_codes_example.md')
0 files changed, 0 insertions, 0 deletions
