ragel-bitmap 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/main.yml +34 -0
- data/.rubocop.yml +26 -2
- data/CHANGELOG.md +19 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile.lock +22 -17
- data/LICENSE +1 -1
- data/README.md +51 -3
- data/bin/bench +92 -0
- data/{bin/replace → exe/ragel-bitmap} +0 -0
- data/lib/ragel/bitmap/replace.rb +59 -13
- data/lib/ragel/bitmap/version.rb +1 -1
- data/lib/ragel/bitmap.rb +36 -0
- data/ragel-bitmap.gemspec +18 -10
- metadata +26 -18
- data/.travis.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 178f63cf68da95f64eb11f01ebb4d677fd4d1b3be0a54666e1e729c21e2a2c06
|
4
|
+
data.tar.gz: 4ece2fbcae8b07e5259840f5f934a8af330fa1663a06c13593303d500ff0956d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe356d2518bc0708c5a2792abefde227a00b6f5b20c97ee1f74d2632e937a925ec678a8d51f31e0a6755ea2738cc02bb20f4a17b62142130eed9588c00be6a1f
|
7
|
+
data.tar.gz: cf6b3b9f269e29093f528f33b2c46a8e8ef4c174d9c4104c91fc356140ab467a5b8ca5055868edd05d8037931dcdf4a92c9b2d01f451c14d35d2e2d8ba1581c0
|
@@ -0,0 +1,34 @@
|
|
1
|
+
name: Main
|
2
|
+
on:
|
3
|
+
- push
|
4
|
+
- pull_request_target
|
5
|
+
jobs:
|
6
|
+
ci:
|
7
|
+
name: CI
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
env:
|
10
|
+
CI: true
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@master
|
13
|
+
- uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 3.0
|
16
|
+
bundler-cache: true
|
17
|
+
- name: Lint and test
|
18
|
+
run: |
|
19
|
+
bundle exec rubocop --parallel
|
20
|
+
bundle exec rake test
|
21
|
+
automerge:
|
22
|
+
name: AutoMerge
|
23
|
+
needs: ci
|
24
|
+
runs-on: ubuntu-latest
|
25
|
+
if: github.event_name == 'pull_request_target' && (github.actor == github.repository_owner || github.actor == 'dependabot[bot]')
|
26
|
+
steps:
|
27
|
+
- uses: actions/github-script@v3
|
28
|
+
with:
|
29
|
+
script: |
|
30
|
+
github.pulls.merge({
|
31
|
+
owner: context.payload.repository.owner.login,
|
32
|
+
repo: context.payload.repository.name,
|
33
|
+
pull_number: context.payload.pull_request.number
|
34
|
+
})
|
data/.rubocop.yml
CHANGED
@@ -1,10 +1,34 @@
|
|
1
1
|
AllCops:
|
2
2
|
DisplayCopNames: true
|
3
3
|
DisplayStyleGuide: true
|
4
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.7
|
5
5
|
Exclude:
|
6
|
+
- '{tmp,vendor,yard}/**/*'
|
6
7
|
- 'test/ragel/fixtures/*'
|
7
|
-
|
8
|
+
|
9
|
+
Gemspec/RequiredRubyVersion:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Layout/LineLength:
|
13
|
+
Max: 80
|
14
|
+
|
15
|
+
Lint/AmbiguousBlockAssociation:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Naming/RescuedExceptionsVariableName:
|
19
|
+
Enabled: false
|
8
20
|
|
9
21
|
Style/Documentation:
|
10
22
|
Enabled: false
|
23
|
+
|
24
|
+
Style/FormatString:
|
25
|
+
EnforcedStyle: percent
|
26
|
+
|
27
|
+
Style/FormatStringToken:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/PerlBackrefs:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/SlicingWithRange:
|
34
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.2.2] - 2021-11-17
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- Take advantage of the new `unpack1` `offset` option.
|
14
|
+
- Require MFA for releasing.
|
15
|
+
|
16
|
+
## [0.2.1] - 2019-07-10
|
17
|
+
|
18
|
+
[unreleased]: https://github.com/kddnewton/ragel-bitmap/compare/v0.2.1...HEAD
|
19
|
+
[0.2.1]: https://github.com/kddnewton/ragel-bitmap/compare/bb72cc...v0.2.1
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
55
55
|
## Enforcement
|
56
56
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at
|
58
|
+
reported by contacting the project team at kddnewton@gmail.com. All
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
data/Gemfile.lock
CHANGED
@@ -1,28 +1,33 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ragel-bitmap (0.2.
|
4
|
+
ragel-bitmap (0.2.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
ast (~> 2.4.0)
|
9
|
+
ast (2.4.2)
|
10
|
+
minitest (5.14.4)
|
11
|
+
parallel (1.21.0)
|
12
|
+
parser (3.0.2.0)
|
13
|
+
ast (~> 2.4.1)
|
15
14
|
rainbow (3.0.0)
|
16
|
-
rake (
|
17
|
-
|
18
|
-
|
15
|
+
rake (13.0.6)
|
16
|
+
regexp_parser (2.1.1)
|
17
|
+
rexml (3.2.5)
|
18
|
+
rubocop (1.23.0)
|
19
19
|
parallel (~> 1.10)
|
20
|
-
parser (>=
|
20
|
+
parser (>= 3.0.0.0)
|
21
21
|
rainbow (>= 2.2.2, < 4.0)
|
22
|
+
regexp_parser (>= 1.8, < 3.0)
|
23
|
+
rexml
|
24
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
22
25
|
ruby-progressbar (~> 1.7)
|
23
|
-
unicode-display_width (>= 1.4.0, <
|
24
|
-
|
25
|
-
|
26
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
27
|
+
rubocop-ast (1.13.0)
|
28
|
+
parser (>= 3.0.1.1)
|
29
|
+
ruby-progressbar (1.11.0)
|
30
|
+
unicode-display_width (2.1.0)
|
26
31
|
|
27
32
|
PLATFORMS
|
28
33
|
ruby
|
@@ -31,8 +36,8 @@ DEPENDENCIES
|
|
31
36
|
bundler (~> 2.0)
|
32
37
|
minitest (~> 5.11)
|
33
38
|
ragel-bitmap!
|
34
|
-
rake (~>
|
35
|
-
rubocop (~>
|
39
|
+
rake (~> 13.0)
|
40
|
+
rubocop (~> 1.12)
|
36
41
|
|
37
42
|
BUNDLED WITH
|
38
|
-
2.0.
|
43
|
+
2.3.0.dev
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,55 @@
|
|
1
1
|
# Ragel::Bitmap
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://github.com/kddnewton/ragel-bitmap/workflows/Main/badge.svg)](https://github.com/kddnewton/ragel-bitmap/actions)
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/ragel-bitmap.svg)](https://rubygems.org/gems/ragel-bitmap)
|
4
5
|
|
5
6
|
[Ragel](https://www.colm.net/open-source/ragel/) generates ruby code with very large arrays of integers that allocate a lot of memory when required. To reduce memory consumption, this gem replaces those arrays with packed strings.
|
6
7
|
|
8
|
+
For example, let's say you have a very large array of 8-bit unsigned integers (like ragel generates for small parsers). In a lot of places where ragel needs to jump between states, it will interject arrays like:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
self.transitions =
|
12
|
+
[206, 28, 108, 253, 151, 248, 208, 13, 97, 74]
|
13
|
+
```
|
14
|
+
|
15
|
+
For a small array like this, that's not a big deal. But for some very large parsers, that can add up to [a lot of memory overhead](https://github.com/micke/valid_email2/issues/165) even just to parse the file. Using this gem, that line of code would be replaced instead with:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
self.transitions =
|
19
|
+
Ragel::Bitmap::Array8.new("\xCE\x1Cl\xFD\x97\xF8\xD0\raJ")
|
20
|
+
```
|
21
|
+
|
22
|
+
Since the only method that ragel uses on these arrays is `#[]`, that method is implemented as well on `Array8`, which makes it possible to swap this code in seemlessly.
|
23
|
+
|
24
|
+
In a lot of cases the numbers contained in these arrays won't quite fit into 8-bit unsigned integers, more often it's 16-bits that you end up needing. For that we use `Ragel::Bitmap::Array16`, as in:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
self.transitions =
|
28
|
+
[22427, 6684, 39361, 52842, 12850, 37505, 53824, 5861, 51699, 63533]
|
29
|
+
```
|
30
|
+
|
31
|
+
becomes:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
self.transitions =
|
35
|
+
Ragel::Bitmap::Array16.new(
|
36
|
+
"W\x1A\x99\xCE2\x92\xD2\x16\xC9\xF8",
|
37
|
+
"\x9B\x1C\xC1j2\x81@\xE5\xF3-"
|
38
|
+
)
|
39
|
+
```
|
40
|
+
|
41
|
+
The two string arguments being given to the `::new` method there signify the high and low byte of each of the numbers, respectively. Then, when we go to pull the numbers back out, we simply get the 8-bit segments from each of the high and low bytes, shift the high byte left by 8 bits, and bitwise-or them together.
|
42
|
+
|
43
|
+
This kind of approach works for any size integer, because we can keep splitting it up into multiple bytes. We have explicit support for:
|
44
|
+
|
45
|
+
* `Array8` - 1-byte integers
|
46
|
+
* `Array16` - 2-byte integers
|
47
|
+
* `Array24` - 3-byte integers
|
48
|
+
* `Array32` - 4-byte integers
|
49
|
+
* `Array32Offset` - 4-byte integers using `unpack1` with the offset parameter, available since [3.1.0](https://bugs.ruby-lang.org/issues/18254)
|
50
|
+
* `Array64Offset` - 8-byte integers using `unpack1` with the offset parameter, available since [3.1.0](https://bugs.ruby-lang.org/issues/18254)
|
51
|
+
* `ArrayGeneric` - functions with any size integer
|
52
|
+
|
7
53
|
## Installation
|
8
54
|
|
9
55
|
Add this line to your application's Gemfile:
|
@@ -22,7 +68,7 @@ Or install it yourself as:
|
|
22
68
|
|
23
69
|
## Usage
|
24
70
|
|
25
|
-
After you've run `ragel` to generate your parser, you should then run this gem over the resulting source file and it will replace the integer arrays
|
71
|
+
After you've run `ragel` to generate your parser, you should then run this gem over the resulting source file and it will replace the integer arrays with our specialized array substitutions. For example, the following code adds a rake rule to generate the ragel parser from the grammar file and then run `Ragel::Bitmap` over it:
|
26
72
|
|
27
73
|
```ruby
|
28
74
|
rule %r|_parser\.rb\z| => '%X.rl' do |t|
|
@@ -34,6 +80,8 @@ end
|
|
34
80
|
|
35
81
|
Then, in your application, add `require 'ragel/bitmap'` before you require your parser. Now you should be off and running!
|
36
82
|
|
83
|
+
We also provide a `ragel-bitmap` command that you can execute once this gem is installed. Usage looks like `ragel-bitmap [path]` where `path` is a path to a generated ragel parser.
|
84
|
+
|
37
85
|
## Development
|
38
86
|
|
39
87
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -42,7 +90,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
42
90
|
|
43
91
|
## Contributing
|
44
92
|
|
45
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
93
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kddnewton/ragel-bitmap.
|
46
94
|
|
47
95
|
## License
|
48
96
|
|
data/bin/bench
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/inline'
|
5
|
+
|
6
|
+
gemfile do
|
7
|
+
source 'https://rubygems.org'
|
8
|
+
gem 'benchmark-ips'
|
9
|
+
end
|
10
|
+
|
11
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
|
12
|
+
require 'ragel/bitmap'
|
13
|
+
|
14
|
+
numbers = Array.new(10_000) { rand(2**16) }
|
15
|
+
offsets = numbers.pack('S*')
|
16
|
+
|
17
|
+
high = numbers.map { |number| number >> 8 }.pack('C*')
|
18
|
+
low = numbers.pack('C*')
|
19
|
+
|
20
|
+
# Here we're measuring if it's faster to use unpack1 with offset or if it's
|
21
|
+
# faster to keep two separate strings around, use getbyte, and | them together
|
22
|
+
# for 16-byte unsigned integers.
|
23
|
+
Benchmark.ips do |x|
|
24
|
+
x.report('16-byte offsets') do
|
25
|
+
index = rand(10_000)
|
26
|
+
offsets.unpack1('S', offset: index)
|
27
|
+
end
|
28
|
+
|
29
|
+
x.report('16-byte strings') do
|
30
|
+
index = rand(10_000)
|
31
|
+
(high.getbyte(index) << 8) | low.getbyte(index)
|
32
|
+
end
|
33
|
+
|
34
|
+
x.compare!
|
35
|
+
end
|
36
|
+
|
37
|
+
numbers = Array.new(10_000) { rand(2**32) }
|
38
|
+
offsets = numbers.pack('L*')
|
39
|
+
high, midhigh, midlow, low =
|
40
|
+
[24, 16, 8, 0].map do |shift|
|
41
|
+
numbers.map { |number| number >> shift }.pack('C*')
|
42
|
+
end
|
43
|
+
|
44
|
+
# Here we're measuring the same difference but this time we're using 32-byte
|
45
|
+
# unsigned integers instead.
|
46
|
+
Benchmark.ips do |x|
|
47
|
+
x.report('32-byte offsets') do
|
48
|
+
index = rand(10_000)
|
49
|
+
offsets.unpack1('L', offset: index)
|
50
|
+
end
|
51
|
+
|
52
|
+
x.report('32-byte strings') do
|
53
|
+
index = rand(10_000)
|
54
|
+
(high.getbyte(index) << 24) |
|
55
|
+
(midhigh.getbyte(index) << 16) |
|
56
|
+
(midlow.getbyte(index) << 8) |
|
57
|
+
low.getbyte(index)
|
58
|
+
end
|
59
|
+
|
60
|
+
x.compare!
|
61
|
+
end
|
62
|
+
|
63
|
+
numbers = Array.new(10_000) { rand(2**64) }
|
64
|
+
offsets = numbers.pack('Q*')
|
65
|
+
highest, midhighest, high, midhigh, midlow, low, midlowest, lowest =
|
66
|
+
[56, 48, 40, 32, 24, 16, 8, 0].map do |shift|
|
67
|
+
numbers.map { |number| number >> shift }.pack('C*')
|
68
|
+
end
|
69
|
+
|
70
|
+
# Here we're measuring the same difference but this time we're using 64-byte
|
71
|
+
# unsigned integers instead.
|
72
|
+
Benchmark.ips do |x|
|
73
|
+
x.report('64-byte offsets') do
|
74
|
+
index = rand(10_000)
|
75
|
+
offsets.unpack1('Q', offset: index)
|
76
|
+
end
|
77
|
+
|
78
|
+
x.report('64-byte strings') do
|
79
|
+
index = rand(10_000)
|
80
|
+
|
81
|
+
(highest.getbyte(index) << 56) |
|
82
|
+
(midhighest.getbyte(index) << 48) |
|
83
|
+
(high.getbyte(index) << 40) |
|
84
|
+
(midhigh.getbyte(index) << 32) |
|
85
|
+
(midlow.getbyte(index) << 24) |
|
86
|
+
(low.getbyte(index) << 16) |
|
87
|
+
(midlowest.getbyte(index) << 8) |
|
88
|
+
lowest.getbyte(index)
|
89
|
+
end
|
90
|
+
|
91
|
+
x.compare!
|
92
|
+
end
|
File without changes
|
data/lib/ragel/bitmap/replace.rb
CHANGED
@@ -9,26 +9,72 @@ module Ragel
|
|
9
9
|
class Replace < Ripper::SexpBuilderPP
|
10
10
|
class << self
|
11
11
|
# Get the required args for a bitmap from a set of numbers
|
12
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
12
13
|
def bitmap_args_from(numbers)
|
13
14
|
size = (Math.log2(numbers.max) / 8).ceil
|
14
|
-
strings =
|
15
|
-
size.downto(1).map do |index|
|
16
|
-
shift = (index - 1) * 8
|
17
|
-
numbers.map { |number| (number >> shift) & 0xff }.pack('C*')
|
18
|
-
end
|
19
15
|
|
20
|
-
|
16
|
+
case size
|
17
|
+
when 1
|
18
|
+
[:Array8, [numbers.pack('C*')]]
|
19
|
+
when 2
|
20
|
+
[:Array16, strings_from(2, numbers)]
|
21
|
+
when 3
|
22
|
+
[:Array24, strings_from(3, numbers)]
|
23
|
+
when 4
|
24
|
+
if offset?
|
25
|
+
[:Array32Offset, [numbers.pack('L*')]]
|
26
|
+
else
|
27
|
+
[:Array32, strings_from(4, numbers)]
|
28
|
+
end
|
29
|
+
when 8
|
30
|
+
if offset?
|
31
|
+
[:Array64Offset, [numbers.pack('Q*')]]
|
32
|
+
else
|
33
|
+
[:ArrayGeneric, strings_from(size, numbers)]
|
34
|
+
end
|
35
|
+
else
|
36
|
+
[:ArrayGeneric, strings_from(size, numbers)]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
40
|
+
|
41
|
+
# Check if we can use the offset keyword argument for the unpack1 method
|
42
|
+
# introduced here: https://bugs.ruby-lang.org/issues/18254. If we can,
|
43
|
+
# then it'll be more efficient than storing multiple strings and
|
44
|
+
# shifting.
|
45
|
+
def offset?
|
46
|
+
String.instance_method(:unpack1).parameters.any? do |(type, name)|
|
47
|
+
type == :key && name == :offset
|
48
|
+
end
|
21
49
|
end
|
22
50
|
|
23
51
|
private
|
24
52
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
53
|
+
# This will take a set of numbers and return a set of strings that
|
54
|
+
# represent their bytes in the same order. For example, if you passed in
|
55
|
+
# the numbers [10, 100, 1000] and said to encode them into 2 strings,
|
56
|
+
# you would receive back the strings:
|
57
|
+
#
|
58
|
+
# "\x00\x00\x03"
|
59
|
+
# "\x0a\x64\xe8"
|
60
|
+
#
|
61
|
+
# Read vertically, (with the first one being the higher byte) you'll
|
62
|
+
# see they add up to the input numbers. See the work below:
|
63
|
+
#
|
64
|
+
# 0x000a = 0d0010
|
65
|
+
# 0x0064 = 0d0100
|
66
|
+
# 0x03e8 = 0d1000
|
67
|
+
#
|
68
|
+
# To get the original numbers back, we can do much the same as we just
|
69
|
+
# did in that example, which is to read the strings in highest to lowest
|
70
|
+
# byte order, getting the bytes out at the same index every time. Then
|
71
|
+
# for each high string, shifting it left the requisite number of bytes
|
72
|
+
# (in the example above it's 8 since it's just 2 strings, if it were 3
|
73
|
+
# strings then the first string would be shifted by 16, and so on).
|
74
|
+
def strings_from(size, numbers)
|
75
|
+
size.downto(1).map do |index|
|
76
|
+
shift = (index - 1) * 8
|
77
|
+
numbers.map { |number| (number >> shift) & 0xff }.pack('C*')
|
32
78
|
end
|
33
79
|
end
|
34
80
|
end
|
data/lib/ragel/bitmap/version.rb
CHANGED
data/lib/ragel/bitmap.rb
CHANGED
@@ -48,6 +48,42 @@ module Ragel
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
class Array32
|
52
|
+
def initialize(first, second, third, fourth)
|
53
|
+
@first = first
|
54
|
+
@second = second
|
55
|
+
@third = third
|
56
|
+
@fourth = fourth
|
57
|
+
end
|
58
|
+
|
59
|
+
def [](idx)
|
60
|
+
(@first.getbyte(idx) << 24) |
|
61
|
+
(@second.getbyte(idx) << 16) |
|
62
|
+
(@third.getbyte(idx) << 8) |
|
63
|
+
@fourth.getbyte(idx)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class Array32Offset
|
68
|
+
def initialize(string)
|
69
|
+
@string = string
|
70
|
+
end
|
71
|
+
|
72
|
+
def [](idx)
|
73
|
+
@string.unpack1('L', offset: idx * 4)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class Array64Offset
|
78
|
+
def initialize(string)
|
79
|
+
@string = string
|
80
|
+
end
|
81
|
+
|
82
|
+
def [](idx)
|
83
|
+
@string.unpack1('Q', offset: idx * 8)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
51
87
|
class ArrayGeneric
|
52
88
|
def initialize(*strings)
|
53
89
|
@strings = strings
|
data/ragel-bitmap.gemspec
CHANGED
@@ -1,20 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require_relative 'lib/ragel/bitmap/version'
|
4
|
+
|
5
|
+
version = Ragel::Bitmap::VERSION
|
6
|
+
repository = 'https://github.com/kddnewton/ragel-bitmap'
|
6
7
|
|
7
8
|
Gem::Specification.new do |spec|
|
8
9
|
spec.name = 'ragel-bitmap'
|
9
|
-
spec.version =
|
10
|
-
spec.authors = ['Kevin
|
11
|
-
spec.email = ['
|
10
|
+
spec.version = version
|
11
|
+
spec.authors = ['Kevin Newton']
|
12
|
+
spec.email = ['kddnewton@gmail.com']
|
12
13
|
|
13
14
|
spec.summary = 'Use bitmaps for ragel-generated code instead of arrays'
|
14
|
-
spec.homepage =
|
15
|
+
spec.homepage = repository
|
15
16
|
spec.license = 'MIT'
|
16
17
|
|
17
|
-
spec.
|
18
|
+
spec.metadata = {
|
19
|
+
'bug_tracker_uri' => "#{repository}/issues",
|
20
|
+
'changelog_uri' => "#{repository}/blob/v#{version}/CHANGELOG.md",
|
21
|
+
'source_code_uri' => repository,
|
22
|
+
'rubygems_mfa_required' => 'true'
|
23
|
+
}
|
24
|
+
|
25
|
+
spec.files =
|
18
26
|
Dir.chdir(File.expand_path(__dir__)) do
|
19
27
|
`git ls-files -z`.split("\x0").reject do |f|
|
20
28
|
f.match(%r{^(test|spec|features)/})
|
@@ -27,6 +35,6 @@ Gem::Specification.new do |spec|
|
|
27
35
|
|
28
36
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
29
37
|
spec.add_development_dependency 'minitest', '~> 5.11'
|
30
|
-
spec.add_development_dependency 'rake', '~>
|
31
|
-
spec.add_development_dependency 'rubocop', '~>
|
38
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
39
|
+
spec.add_development_dependency 'rubocop', '~> 1.12'
|
32
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ragel-bitmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Kevin
|
8
|
-
autorequire:
|
7
|
+
- Kevin Newton
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,56 +44,64 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '1.12'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
-
description:
|
68
|
+
version: '1.12'
|
69
|
+
description:
|
70
70
|
email:
|
71
|
-
-
|
72
|
-
executables:
|
71
|
+
- kddnewton@gmail.com
|
72
|
+
executables:
|
73
|
+
- ragel-bitmap
|
73
74
|
extensions: []
|
74
75
|
extra_rdoc_files: []
|
75
76
|
files:
|
77
|
+
- ".github/dependabot.yml"
|
78
|
+
- ".github/workflows/main.yml"
|
76
79
|
- ".gitignore"
|
77
80
|
- ".rubocop.yml"
|
78
|
-
-
|
81
|
+
- CHANGELOG.md
|
79
82
|
- CODE_OF_CONDUCT.md
|
80
83
|
- Gemfile
|
81
84
|
- Gemfile.lock
|
82
85
|
- LICENSE
|
83
86
|
- README.md
|
84
87
|
- Rakefile
|
88
|
+
- bin/bench
|
85
89
|
- bin/console
|
86
|
-
- bin/replace
|
87
90
|
- bin/setup
|
91
|
+
- exe/ragel-bitmap
|
88
92
|
- lib/ragel/bitmap.rb
|
89
93
|
- lib/ragel/bitmap/replace.rb
|
90
94
|
- lib/ragel/bitmap/version.rb
|
91
95
|
- ragel-bitmap.gemspec
|
92
|
-
homepage: https://github.com/
|
96
|
+
homepage: https://github.com/kddnewton/ragel-bitmap
|
93
97
|
licenses:
|
94
98
|
- MIT
|
95
|
-
metadata:
|
96
|
-
|
99
|
+
metadata:
|
100
|
+
bug_tracker_uri: https://github.com/kddnewton/ragel-bitmap/issues
|
101
|
+
changelog_uri: https://github.com/kddnewton/ragel-bitmap/blob/v0.2.2/CHANGELOG.md
|
102
|
+
source_code_uri: https://github.com/kddnewton/ragel-bitmap
|
103
|
+
rubygems_mfa_required: 'true'
|
104
|
+
post_install_message:
|
97
105
|
rdoc_options: []
|
98
106
|
require_paths:
|
99
107
|
- lib
|
@@ -108,8 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
116
|
- !ruby/object:Gem::Version
|
109
117
|
version: '0'
|
110
118
|
requirements: []
|
111
|
-
rubygems_version: 3.0.
|
112
|
-
signing_key:
|
119
|
+
rubygems_version: 3.3.0.dev
|
120
|
+
signing_key:
|
113
121
|
specification_version: 4
|
114
122
|
summary: Use bitmaps for ragel-generated code instead of arrays
|
115
123
|
test_files: []
|