Faster String#blank?#12976
Conversation
|
❤️ |
|
The biggest caller here is Perhaps |
|
Tried |
|
@tmm1 if we change |
|
|
|
The new regex covers the empty? case pretty fast already, so adding the conditional only makes it slower. We want to avoid the regex in the common |
|
Yeah - hence implementing |
|
Isn't just string search faster? or should it match other non-space sybmols |
|
@homakov please translate "string search" from English code to Ruby code and run the benchmark 😁 |
|
this seems to be fastest |
|
@jeremy nevermind, i meant just searching for ' ' but then i understood tabs/new lines are also space chars... |
|
fast_blank ftw :) https://github.com/SamSaffron/fast_blank/blob/master/benchmark agree with @tmm1 this is often heavily overused |
|
@homakov run my test suite to ensure 100% parity. |
Our rails app spends 2-3% of production cpu time in this method:
This pull request optimizes the regex in this method slightly by removing the double negative.