-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from tjschuck/readme_updates
README updates
- Loading branch information
Showing
1 changed file
with
17 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
### String blank? Ruby Extension | ||
### `String#blank?` Ruby Extension | ||
|
||
[![Gem Version](https://badge.fury.io/rb/fast_blank.png)](http://badge.fury.io/rb/fast_blank) [![Build Status](https://travis-ci.org/SamSaffron/fast_blank.png?branch=master)](https://travis-ci.org/SamSaffron/fast_blank) | ||
|
||
`fast_blank` is a simple extension which provides a fast implementation of active support's string#blank? function | ||
`fast_blank` is a simple C extension which provides a fast implementation of [Active Support's `String#blank?` method](http://api.rubyonrails.org/classes/String.html#method-i-blank-3F). | ||
|
||
### How do you use it? | ||
|
||
require 'fast_blank' | ||
|
||
### How fast is "Fast"? | ||
|
||
|
||
About 5-9x faster than current active support, on my machine (your mileage my vary): | ||
About 3.5–8x faster than Active Support on my machine (your mileage my vary): | ||
|
||
$ ./benchmark | ||
|
||
|
@@ -34,30 +33,28 @@ Fast Blank (Active Support) 136 : 0.120000 0.000000 0.120000 ( 0.1206 | |
Slow Blank 136 : 0.540000 0.000000 0.540000 ( 0.545197) | ||
``` | ||
|
||
|
||
Additionally, this gem allocates no strings during the test, making it less of a GC burden. | ||
|
||
### Compatibility note: | ||
|
||
###Compatibility note: | ||
|
||
fast_blank is supported under MRI Ruby 1.9.3, 2.0 and 2.1, earlier versions of MRI are untested. | ||
`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 it implemented, meaning it has 100% parity with `String#strip.length == 0`. | ||
`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. | ||
|
||
Active Supports version looks also at 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. | ||
### Credits | ||
|
||
fast_blank also provides blank_as? which is a 100% compatible blank? replacement. | ||
|
||
Author: Sam Saffron [email protected] | ||
http://github.com/SamSaffron/fast_blank | ||
License: MIT | ||
* Author: Sam Saffron ([email protected]) | ||
* https://github.com/SamSaffron/fast_blank | ||
* License: MIT | ||
* Gem template based on [CodeMonkeySteve/fast_xor](https://github.com/CodeMonkeySteve/fast_xor) | ||
|
||
### Change log: | ||
|
||
0.0.2: | ||
- Removed rake dependency (tmm1) | ||
- Unrolled internal loop to improve perf (tmm1) | ||
1.0.0: | ||
- Adds Ruby 2.2 support ([@tjschuck](https://github.com/tjschuck) — [#9](https://github.com/SamSaffron/fast_blank/pull/9)) | ||
|
||
(gem template based on https://github.com/CodeMonkeySteve/fast_xor ) | ||
0.0.2: | ||
- Removed rake dependency ([@tmm1](https://github.com/tmm1) — [#2](https://github.com/SamSaffron/fast_blank/pull/2)) | ||
- Unrolled internal loop to improve perf ([@tmm1](https://github.com/tmm1) — [#2](https://github.com/SamSaffron/fast_blank/pull/2)) |