From 9067a1f47f58281a3536e0a651680a346e2c7f2c Mon Sep 17 00:00:00 2001 From: kocotom Date: Sun, 31 Mar 2024 04:35:08 +0200 Subject: [PATCH] [[unlikely]] attribute added, comments fixed --- include/mata/utils/extendable-square-matrix.hh | 4 ++-- src/partition.cc | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/mata/utils/extendable-square-matrix.hh b/include/mata/utils/extendable-square-matrix.hh index d0bee400c..aceb5f3c0 100644 --- a/include/mata/utils/extendable-square-matrix.hh +++ b/include/mata/utils/extendable-square-matrix.hh @@ -208,7 +208,7 @@ class ExtendableSquareMatrix { size_t size = this->size(); for(size_t i = 0; i < size; ++i) { for(size_t j = 0; j < size; ++j) { - if(i == j) { continue; } + if(i == j) [[unlikely]] { continue; } if(get(i, j) && get(j, i)) { return false; } } } @@ -408,7 +408,7 @@ class CascadeSquareMatrix : public ExtendableSquareMatrix { * capacity of the vector 'data_' since the default vector * assignment does not preserve it. * @brief assignment operator for the CascadeSquareMatrix class - * @param[in] other matrix which should be copied assigned + * @param[in] other matrix which should be assigned */ CascadeSquareMatrix& operator=(const CascadeSquareMatrix& other) { // initialization of the matrix diff --git a/src/partition.cc b/src/partition.cc index 480199644..9ab9278ed 100644 --- a/src/partition.cc +++ b/src/partition.cc @@ -118,7 +118,9 @@ Partition::Partition(size_t num_of_states, const StateBlocks& partition) { // if there is at least one unused state, we need to // create an additional block - if(all_states_used) { + // this branch will be executed only once (first time it is reached) + // and then it will be never executed again + if(all_states_used) [[unlikely]] { all_states_used = false; first = state; ++num_of_blocks; @@ -275,7 +277,7 @@ bool Partition::in_same_block(State first, State second) const { * @return true iff all of the given states belong to the same partition block */ bool Partition::in_same_block(const std::vector& states) const { - if(states.empty()) { return true; } + if(states.empty()) [[unlikely]] { return true; } size_t block_idx = get_block_idx_from_state(states.front()); for(size_t state : states) { assert(state < states_.size() && "The given state does not exist."); @@ -366,7 +368,7 @@ std::vector Partition::split_blocks( std::vector split{}; // if there is no marked state, no block could be split - if(marked.empty()) { return split; } + if(marked.empty()) [[unlikely]] { return split; } // this vector contains information about states which has been marked // and helps to detect states which has been marked multiple times