百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

fast_blank

> 编程语言
开源

String#blank? Ruby 扩展 [](https://GitHub.com/SamSaffron/fastblank/actions/workflows/test.yml) fastblank 是一个简单的 C 扩展,它可以…

616 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

String#blank? Ruby 扩展 [](https://GitHub.com/SamSaffron/fastblank/actions/workflows/test.yml) fastblank 是一个简单的 C 扩展,它可以…

String#blank? Ruby Extension

fast_blank is a simple C extension which provides a fast implementation of Active Support's String#blank? method.

How do you use it?

require 'fast_blank'

or add it to your Bundler Gemfile

gem 'fast_blank'

How fast is "Fast"?

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.

Compatibility note:

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.

Credits

  • Author: Sam Saffron ([email protected])
  • https://github.com/SamSaffron/fast_blank
  • License: MIT
  • Gem template based on CodeMonkeySteve/fast_xor

Change log:

1.0.1:

  • Minor, avoid warnings if redefining blank?

1.0.0:

  • Adds Ruby 2.2 support (@tjschuck — #9)

0.0.2:

  • Removed rake dependency (@tmm1 — #2)
  • Unrolled internal loop to improve perf (@tmm1 — #2)

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言