From fc3e8ab9260b0b679e61a8d1071dff4782f74cca Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 31 Mar 2022 22:07:56 +0200 Subject: [PATCH] Little Sonar things. --- examples/python/comm-serialize/comm-serialize.py | 2 +- src/bindings/python/simgrid_python.cpp | 2 +- src/kernel/lmm/System.cpp | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/python/comm-serialize/comm-serialize.py b/examples/python/comm-serialize/comm-serialize.py index e02708f2fa..f3e8ef13db 100644 --- a/examples/python/comm-serialize/comm-serialize.py +++ b/examples/python/comm-serialize/comm-serialize.py @@ -46,7 +46,7 @@ class Receiver(object): # List in which we store all incoming msgs pending_comms: List[Tuple[Comm, PyGetAsync]] = [] this_actor.info(f"Wait for {self.messages_count} messages asynchronously") - for i in range(self.messages_count): + for _ in range(self.messages_count): pending_comms.append(self.mailbox.get_async()) while pending_comms: index = Comm.wait_any([comm for (comm, _) in pending_comms]) diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 78f34a2ede..4b09a553ce 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -722,7 +722,7 @@ PYBIND11_MODULE(simgrid, m) "Retrieve the mailbox on which this comm acts.") .def_property_readonly("sender", &Comm::get_sender, py::call_guard()) - .def_property_readonly("state_str", [](Comm* self){ return std::string(self->get_state_str()); }, + .def_property_readonly("state_str", [](const Comm* self){ return std::string(self->get_state_str()); }, py::call_guard(), "Retrieve the Comm state as string") .def_property_readonly("remaining", &Comm::get_remaining, diff --git a/src/kernel/lmm/System.cpp b/src/kernel/lmm/System.cpp index fcf84f3b5b..7d803082fb 100644 --- a/src/kernel/lmm/System.cpp +++ b/src/kernel/lmm/System.cpp @@ -277,10 +277,9 @@ void System::expand(Constraint* cnst, Variable* var, double consumption_weight) auto elem_it = std::find_if(begin(var->cnsts_), end(var->cnsts_), [&cnst](Element const& x) { return x.constraint == cnst; }); - if (elem_it != end(var->cnsts_)) { + if (elem_it != end(var->cnsts_) && var->sharing_penalty_ != 0.0) { /* before changing it, decreases concurrency on constraint, it'll be added back later */ - if (var->sharing_penalty_ != 0.0) - elem_it->decrease_concurrency(); + elem_it->decrease_concurrency(); } Element& elem = elem_it != end(var->cnsts_) ? expand_add_to_elem(*elem_it, cnst, consumption_weight) : expand_create_elem(cnst, var, consumption_weight); -- 2.20.1