Skip to content

Commit

Permalink
[[unlikely]] attribute added, comments fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
kocotom committed Mar 31, 2024
1 parent a3a3d6d commit 9067a1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/mata/utils/extendable-square-matrix.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
Expand Down Expand Up @@ -408,7 +408,7 @@ class CascadeSquareMatrix : public ExtendableSquareMatrix<T> {
* 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<T>& operator=(const CascadeSquareMatrix<T>& other) {
// initialization of the matrix
Expand Down
8 changes: 5 additions & 3 deletions src/partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<State>& 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.");
Expand Down Expand Up @@ -366,7 +368,7 @@ std::vector<SplitPair> Partition::split_blocks(
std::vector<SplitPair> 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
Expand Down

0 comments on commit 9067a1f

Please sign in to comment.