bitarray 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f87879a065d489418062f6fb66b5fdf3e9b07360e60491ed7a9908a2c0ac59f
4
- data.tar.gz: eec43c2f9a2589e0d3ca49888229eb54cbf37195f5ea5d2ecd237faca24753a9
3
+ metadata.gz: 8dfa5accb0957e88fd6dca488250f0f22495f1ce5acdd3de74477d644adc7f95
4
+ data.tar.gz: aa10a826fd23bd077346993395ea47a0be789c4c98d5a492b15d9e70943746f3
5
5
  SHA512:
6
- metadata.gz: 83149918dc115df376c8cf01432d0573b26524aac7fdbfac64d229ac70d881f64e60cbbcf15ec9a978acb60c9bfbef62b253165d8f22e5e621c3b374b9389a9a
7
- data.tar.gz: 54c18727b4264b934ef16529b6098ae221f9d10b74a1b39f0ed3d825c42120c8bf79cd95433192f72729b340e17e77cdf1738c9463c75b21bfaf4b57007bea94
6
+ metadata.gz: 63cb034bc5b88a49eeebc8b056c50486959f9a359c1ad45513e14ec66f269962607a4d4829af7bfbde7499db6e9b1bf818d9d7bcce21579feffe59582b455c45
7
+ data.tar.gz: b47a38d9f6a7c9472cac1182c9fe3b6bef6c577812ce9310061ec0d81e3bcba2317fdc951458485b2446ee0ce37b79327cd828c70da31a6f205d6e099f56c46b
data/README.md CHANGED
@@ -4,7 +4,7 @@ A simple, pure-Ruby 'bit field' object.
4
4
 
5
5
  Originally built to help power a bloom filter, although there are other higher level libraries for that task now (https://github.com/igrigorik/bloomfilter-rb is a popular one.)
6
6
 
7
- BitArray has changed little over the years, but has been maintained to work within a typical, modern Ruby environment and, as of February 2024, is confirmed to work with both Ruby 3.0.1 and Ruby 3.3.0.
7
+ BitArray has changed little over the years, but has been maintained to work within a typical, modern Ruby environment and works with Ruby 2.1+ through Ruby 3.x.
8
8
 
9
9
  ## Installation
10
10
 
@@ -64,6 +64,7 @@ ba.to_s # "0000111111110000"
64
64
  ```
65
65
 
66
66
  ## History
67
+ - 1.3.2 in 2026 (minor cleanup, faster total_set)
67
68
  - 1.3.1 in 2024 (no changes other than adding license to gemspec)
68
69
  - 1.3 in 2022 (cleanups and a minor perf tweak)
69
70
  - 1.2 in 2018 (Added option to skip reverse the bits for each byte by @dalibor)
@@ -84,4 +85,4 @@ Further thanks to @tdeo, @JoshuaSP, @dalibor, @yegct and @m1lt0n for pull reques
84
85
 
85
86
  ## License
86
87
 
87
- MIT licensed. Copyright 2007-2024 Peter Cooper.
88
+ MIT licensed. Copyright 2007-2026 Peter Cooper.
data/bitarray.gemspec CHANGED
@@ -14,9 +14,9 @@ Gem::Specification.new do |s|
14
14
  s.license = "MIT"
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
18
  s.require_paths = ["lib"]
19
+ s.required_ruby_version = ">= 2.1"
20
20
 
21
21
  s.add_development_dependency "rake"
22
22
  s.add_development_dependency "minitest"
@@ -2,7 +2,7 @@ class BitArray
2
2
  attr_reader :field, :reverse_byte, :size
3
3
  include Enumerable
4
4
 
5
- VERSION = "1.3.1"
5
+ VERSION = "1.3.2"
6
6
 
7
7
  def initialize(size, field = nil, reverse_byte: true)
8
8
  @size = size
@@ -46,10 +46,8 @@ class BitArray
46
46
  end
47
47
 
48
48
  # Returns the total number of bits that are set
49
- # Use Brian Kernighan's way, see
50
- # https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan
51
49
  def total_set
52
- @field.each_byte.inject(0) { |a, byte| (a += 1; byte &= byte - 1) while byte > 0 ; a }
50
+ @field.unpack1('B*').count('1')
53
51
  end
54
52
 
55
53
  private def byte_position(position)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitarray
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Cooper
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-02-11 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -59,7 +58,6 @@ homepage: https://github.com/peterc/bitarray
59
58
  licenses:
60
59
  - MIT
61
60
  metadata: {}
62
- post_install_message:
63
61
  rdoc_options: []
64
62
  require_paths:
65
63
  - lib
@@ -67,16 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
65
  requirements:
68
66
  - - ">="
69
67
  - !ruby/object:Gem::Version
70
- version: '0'
68
+ version: '2.1'
71
69
  required_rubygems_version: !ruby/object:Gem::Requirement
72
70
  requirements:
73
71
  - - ">="
74
72
  - !ruby/object:Gem::Version
75
73
  version: '0'
76
74
  requirements: []
77
- rubygems_version: 3.5.3
78
- signing_key:
75
+ rubygems_version: 3.6.9
79
76
  specification_version: 4
80
77
  summary: A simple, pure Ruby bit-array / bitfield implementation.
81
- test_files:
82
- - test/test_bit_array.rb
78
+ test_files: []