Skip to content

Commit bb8d21a

Browse files
committed
[sonar] smells--
1 parent f799476 commit bb8d21a

3 files changed

Lines changed: 4 additions & 13 deletions

File tree

include/dtlmod/ActorRegistry.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,15 @@ class ActorRegistry {
3131
ActorRegistry() = default;
3232

3333
void add(sg4::ActorPtr actor) { actors_.insert(actor); }
34-
3534
void remove(sg4::ActorPtr actor) noexcept { actors_.erase(actor); }
36-
3735
[[nodiscard]] bool contains(sg4::ActorPtr actor) const noexcept { return actors_.find(actor) != actors_.end(); }
38-
3936
[[nodiscard]] size_t count() const noexcept { return actors_.size(); }
4037
[[nodiscard]] const std::set<sg4::ActorPtr>& get_all() const noexcept { return actors_; }
4138
[[nodiscard]] bool is_empty() const noexcept { return actors_.empty(); }
4239
[[nodiscard]] sg4::BarrierPtr get_or_create_barrier()
4340
{
4441
if (!barrier_)
45-
barrier_ = sg4::Barrier::create(actors_.size());
42+
barrier_ = sg4::Barrier::create(static_cast<unsigned int>(actors_.size()));
4643
return barrier_;
4744
}
4845
[[nodiscard]] bool is_last_at_barrier() { return barrier_ && barrier_->wait(); }

src/FileEngine.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,8 @@ void FileEngine::end_pub_transaction()
104104
auto transport = std::static_pointer_cast<FileTransport>(transport_);
105105

106106
// This is the end of the first transaction, create a barrier
107-
auto pub_barrier = publishers_.get_or_create_barrier();
108-
if (pub_barrier) {
107+
if (auto pub_barrier = publishers_.get_or_create_barrier())
109108
XBT_DEBUG("Barrier created for %zu publishers", publishers_.count());
110-
}
111109

112110
// Publisher gets the list of files and size to write that has been build during the put() operations
113111
auto to_write = transport->get_to_write_in_transaction_by_actor(self);

src/StagingEngine.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ void StagingEngine::begin_pub_transaction()
6969
void StagingEngine::end_pub_transaction()
7070
{
7171
// This is the end of the first transaction, create a barrier
72-
auto pub_barrier = publishers_.get_or_create_barrier();
73-
if (pub_barrier) {
72+
if (auto pub_barrier = publishers_.get_or_create_barrier())
7473
XBT_DEBUG("Barrier created for %zu publishers", publishers_.count());
75-
}
7674

7775
// A new pub transaction has been completed, notify subscribers that they can starting getting variables
7876
if (is_last_publisher() && (completed_pub_transaction_id_ < current_pub_transaction_id_)) {
@@ -149,10 +147,8 @@ void StagingEngine::begin_sub_transaction()
149147
void StagingEngine::end_sub_transaction()
150148
{
151149
// This is the end of the first transaction, create a barrier
152-
auto sub_barrier = subscribers_.get_or_create_barrier();
153-
if (sub_barrier) {
150+
if (auto sub_barrier = subscribers_.get_or_create_barrier())
154151
XBT_DEBUG("Barrier created for %zu subscribers", subscribers_.count());
155-
}
156152

157153
if (subscribers_.is_last_at_barrier()) {
158154
XBT_DEBUG("Wait for the %d subscribe activities for the transaction", sub_transaction_.size());

0 commit comments

Comments
 (0)