String#blank? Ruby 扩展 [](https://GitHub.com/SamSaffron/fastblank/actions/workflows/test.yml) fastblank 是一个简单的 C 扩展,它可以…
String#blank? Ruby 扩展 [](https://GitHub.com/SamSaffron/fastblank/actions/workflows/test.yml) fastblank 是一个简单的 C 扩展,它可以…
String#blank? Ruby Extensionfast_blank is a simple C extension which provides a fast implementation of Active Support's String#blank? method.
require 'fast_blank'
or add it to your Bundler Gemfile
gem 'fast_blank'
About 1.2–20x faster than Active Support on my machine (your mileage my vary, depends on string length):
…
Additionally, this gem allocates no strings during the test, making it less of a GC burden.
fast_blank supports MRI Ruby 1.9.3, 2.0, 2.1, and 2.2, as well as Rubinius 2.x. Earlier versions of MRI are untested.
fast_blank implements String#blank? as MRI would have implemented it, meaning it has 100% parity with String#strip.length == 0.
Active Support's version also considers Unicode spaces. For example, "\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000".blank? is true in Active Support even though fast_blank would treat it as not blank. Therefore, fast_blank also provides blank_as? which is a 100%-compatible Active Support blank? replacement.
1.0.1:
1.0.0:
0.0.2:
暂无开放 Issues,或尚未同步最近议题。