Recommended fetch with block over args as faster
From https://github.com/rails/rails/pull/26599 i'm seeing that's not the case. Btw, this is a really cool project.
cc/ @timrogers
Thnx @schneems, I'll take a look at it, however I think I will have to make this project ruby-version specific since it seems that speed varies from version to version.
FWIW, I just tried Ruby 1.9.3, 2.3.1, 2.3.3, and 2.4.0, and in all those versions, the argument version was faster than the block version.
see this note on https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code it seems from that that we should make a distinction between a constant argument and method argument.
@gagalago would you be open to creating a PR with a fix for this?
Best, Damir
I can check but I will not do any promise. I am not familiar with code of fasterer (neither from other linters) so I don't know if I will be able to do it.
Sure thing! Lemme know if you need any help figuring anything around the codebase, probably a good start would be checking this method over here: https://github.com/DamirSvrtan/fasterer/blob/master/lib/fasterer/scanners/method_call_scanner.rb#L116
Hey guys, if you don't mind I created a small PR with the fix https://github.com/DamirSvrtan/fasterer/pull/93 Please check it when you have time, probably did something wrong...