| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
I think this PR adds value if you keep the fastest and fast methods, but I feel like slow is doing something way different.
fast and fastest are calling a method on Array (compact vs select) but slow is calling a method on Hash and it's a little too contrived.
Sorry, something went wrong.
|
Thanks for this, @sFrenkie! The core idea is useful, so I've opened #236 which builds on it. One thing to flag: in this version the three expressions aren't quite equivalent. The test data uses boolean values (v < 0.5 → true/false) and contains no nil values, so Hash#values.compact filters nothing while the two select variants also drop false. That makes compact look fastest partly because it's doing less work. #236 uses data that actually contains nil values so all three return the same result (plus an equivalence guard), and adds the README entry. The conclusion still holds: Hash#values.compact is the fastest way to get non-nil values. Closing this in favor of #236 — thanks again for the contribution! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This benchmark proves that get not nil values from hash is fastest with Hash#values#compact