Skip to content

Commit 78eb45e

Browse files
authored
PopCount() => std::popcount() (#11669)
1 parent 5d879a2 commit 78eb45e

21 files changed

+49
-40
lines changed

ydb/core/blobstorage/dsproxy/dsproxy_range.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#include <ydb/core/blobstorage/vdisk/common/vdisk_events.h>
66
#include <ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h>
77

8-
#include <library/cpp/pop_count/popcount.h>
9-
108
namespace NKikimr {
119

1210
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ydb/core/blobstorage/dsproxy/ut_ftol/dsproxy_fault_tolerance_ut_base.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <ydb/library/actors/core/actor_coroutine.h>
77
#include <library/cpp/testing/unittest/registar.h>
88

9+
#include <bit>
10+
911
namespace NKikimr {
1012

1113
template<typename TDerived>
@@ -76,8 +78,8 @@ class TFaultToleranceTestBase : public TActorCoroImpl {
7678
auto layout = GetActualPartLayout(id);
7779
const ui32 disksWithData = layout.GetDisksWithPart(0) | layout.GetDisksWithPart(1);
7880
const ui32 disksWithMetadata = layout.GetDisksWithPart(2);
79-
const ui32 numDisksWithData = PopCount(disksWithData);
80-
const ui32 numDisksWithAny = PopCount(disksWithData | disksWithMetadata);
81+
const ui32 numDisksWithData = std::popcount(disksWithData);
82+
const ui32 numDisksWithAny = std::popcount(disksWithData | disksWithMetadata);
8183
UNIT_ASSERT(numDisksWithAny >= 5);
8284
auto printLayout = [&] {
8385
TStringStream s;

ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
#include <ydb/library/actors/core/interconnect.h>
1212

13-
#include <library/cpp/pop_count/popcount.h>
14-
1513
#include <library/cpp/digest/crc32c/crc32c.h>
1614

1715
#include <util/string/printf.h>
@@ -23,6 +21,8 @@
2321
#include <util/string/type.h>
2422
#include <util/string/cast.h>
2523

24+
#include <bit>
25+
2626
namespace NKikimr {
2727

2828
class TQuorumCheckerBase : public TBlobStorageGroupInfo::IQuorumChecker {
@@ -287,7 +287,7 @@ quitIter: ;
287287
return 0; // we already have a part
288288
}
289289
// filter out only parts on their respective disks to filter out possibly incorrectly written parts
290-
const ui32 numDisksWithPartInMyRing = PopCount((disksWithPart >> myRing) & 0x49); // binary stencil 001001001
290+
const ui32 numDisksWithPartInMyRing = std::popcount((disksWithPart >> myRing) & 0x49); // binary stencil 001001001
291291
// resurrect matching part if there are less than 2 parts in our datacenter
292292
return numDisksWithPartInMyRing < 2 ? 1 << myRing : 0;
293293
}

ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_partlayout.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
#include "blobstorage_groupinfo_sets.h"
33
#include <ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress.h>
44

5+
#include <bit>
6+
57
namespace NKikimr {
68

79
template<typename Iterator>
810
ui32 CountEffectiveReplicasGeneric(Iterator begin, Iterator end, ui32 usedDiskMask = 0) {
911
if (begin == end) {
10-
return PopCount(usedDiskMask);
12+
return std::popcount(usedDiskMask);
1113
}
1214
ui32 value = *begin++ & ~usedDiskMask;
1315
ui32 res = CountEffectiveReplicasGeneric(begin, end, usedDiskMask); // try skipping this disk
@@ -49,7 +51,7 @@ namespace NKikimr {
4951
total &= mainMask;
5052

5153
// count them as effective replicas
52-
ui32 res = PopCount(total);
54+
ui32 res = std::popcount(total);
5355

5456
if (total != mainMask) {
5557
// here we filter out handoff disks containing at least one of required parts (which are indicated
@@ -72,7 +74,7 @@ namespace NKikimr {
7274

7375
case 2: { // two handoff disks contain parts
7476
const ui32 a = handoffDiskByPart[0], b = handoffDiskByPart[1];
75-
res += Min(2U, PopCount(a | b)); // if both disks contain the same part, we can use only one disk
77+
res += Min(2, std::popcount(a | b)); // if both disks contain the same part, we can use only one disk
7678
break;
7779
}
7880

ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_partlayout.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "defs.h"
44
#include "blobstorage_groupinfo.h"
55

6+
#include <bit>
7+
68
namespace NKikimr {
79

810
class TIngress;
@@ -84,7 +86,7 @@ namespace NKikimr {
8486
std::pair<ui32, ui32> GetMirror3of4State() const {
8587
const ui32 data = GetDisksWithPart(0) | GetDisksWithPart(1);
8688
const ui32 meta = GetDisksWithPart(2);
87-
return std::make_tuple(PopCount(data), PopCount(data | meta));
89+
return std::make_tuple<ui32, ui32>(std::popcount(data), std::popcount(data | meta));
8890
}
8991

9092
template<typename F>
@@ -121,7 +123,7 @@ namespace NKikimr {
121123
partMasks.push_back(1 << idxInSubgroup);
122124
} else {
123125
for (ui32 j = 1; j < 1 << gtype.TotalPartCount(); ++j) {
124-
if (PopCount(j) <= maxHandoffBits) {
126+
if (static_cast<ui32>(std::popcount(j)) <= maxHandoffBits) {
125127
partMasks.push_back(j);
126128
}
127129
}

ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_sets.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "defs.h"
44
#include "blobstorage_groupinfo_iter.h"
55

6-
#include <library/cpp/pop_count/popcount.h>
6+
#include <bit>
77

88
namespace NKikimr {
99

@@ -219,7 +219,7 @@ namespace NKikimr {
219219

220220
// calculate number of set bits
221221
ui32 GetNumSetItems() const {
222-
return PopCount(Mask);
222+
return std::popcount(Mask);
223223
}
224224

225225
const TBlobStorageGroupInfo::TTopology *GetTopology() const {

ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_ut.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress.h>
66
#include <library/cpp/testing/unittest/registar.h>
77

8+
#include <bit>
9+
810
namespace NKikimr {
911

1012
Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoTest) {
@@ -147,7 +149,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoTest) {
147149
// calculate sets of disks
148150
TVector<ui32> goodMask, badMask;
149151
for (ui32 mask = 0; mask < numMasks; ++mask) {
150-
(PopCount(mask) <= numHandoff ? goodMask : badMask).push_back(mask);
152+
(static_cast<ui32>(std::popcount(mask)) <= numHandoff ? goodMask : badMask).push_back(mask);
151153
}
152154

153155
auto createGroupVDisks = [&](ui32 domainMask, ui32 vdiskMask) {

ydb/core/blobstorage/groupinfo/defs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#pragma once
22
// unique tag to fix pragma once gcc glueing: ./ydb/core/blobstorage/groupinfo/defs.h
33
#include <ydb/core/blobstorage/defs.h>
4-
#include <library/cpp/pop_count/popcount.h>
54
#include <util/string/escape.h>

ydb/core/blobstorage/groupinfo/ya.make

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ LIBRARY()
33
PEERDIR(
44
ydb/library/actors/core
55
library/cpp/digest/crc32c
6-
library/cpp/pop_count
76
ydb/core/base
87
ydb/core/base/services
98
ydb/core/blobstorage/crypto

ydb/core/blobstorage/ut_blobstorage/osiris.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <util/system/condvar.h>
55
#include <util/system/info.h>
66

7+
#include <bit>
8+
79
#define SINGLE_THREAD 1
810

911
namespace {
@@ -241,7 +243,7 @@ void DoTest(TBlobStorageGroupType::EErasureSpecies erasure) {
241243
v.push_back(1 << i); // main
242244
} else {
243245
for (ui32 j = 1; j < (1 << type.TotalPartCount()); ++j) {
244-
if (PopCount(j) <= 1) {
246+
if (std::popcount(j) <= 1) {
245247
v.push_back(j); // handoff
246248
}
247249
}

0 commit comments

Comments
 (0)