@@ -144,19 +144,13 @@ contains
144
144
integer(bits_kind) :: bit_count
145
145
class(bitset_large), intent(in) :: self
146
146
147
- integer(bits_kind) :: block_ , pos
147
+ integer(bits_kind) :: nblocks , pos
148
148
149
- bit_count = 0
150
- do block_ = 1_bits_kind, size(self % blocks, kind=bits_kind) - 1
151
- do pos = 0, block_size-1
152
- if ( btest( self % blocks(block_), pos ) ) &
153
- bit_count = bit_count + 1
154
- end do
155
-
156
- end do
149
+ nblocks = size( self % blocks, kind=bits_kind )
150
+ bit_count = sum( popcnt( self % blocks(1:nblocks-1) ) )
157
151
158
- do pos = 0_bits_kind, self % num_bits - (block_ -1)*block_size - 1
159
- if ( btest( self % blocks(block_ ), pos ) ) bit_count = bit_count + 1
152
+ do pos = 0_bits_kind, self % num_bits - (nblocks -1)*block_size - 1
153
+ if ( btest( self % blocks(nblocks ), pos ) ) bit_count = bit_count + 1
160
154
end do
161
155
162
156
end function bit_count_large
@@ -1051,7 +1045,7 @@ contains
1051
1045
pure module subroutine set_range_large(self, start_pos, stop_pos)
1052
1046
!
1053
1047
! Sets all valid bits to 1 from the START_POS to the STOP_POS positions
1054
- ! in SELF. If STOP_POA < START_POS no bits are changed. Positions outside
1048
+ ! in SELF. If STOP_POS < START_POS no bits are changed. Positions outside
1055
1049
! the range 0 to BITS(SELF)-1 are ignored.
1056
1050
!
1057
1051
class(bitset_large), intent(inout) :: self
0 commit comments