Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src/util/sharing_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Author: Daniel Poetzl
#define CPROVER_UTIL_SHARING_MAP_H

#ifdef SM_DEBUG
#include <iostream>
# include <iostream>
#endif

#include <functional>
Expand All @@ -34,9 +34,9 @@ Author: Daniel Poetzl
#include "threeval.h"

#ifdef SM_INTERNAL_CHECKS
#define SM_ASSERT(b) INVARIANT(b, "Sharing map internal invariant")
# define SM_ASSERT(b) INVARIANT(b, "Sharing map internal invariant")
#else
#define SM_ASSERT(b)
# define SM_ASSERT(b)
#endif

// clang-format off
Expand Down Expand Up @@ -344,8 +344,8 @@ class sharing_mapt
map.swap(other.map);

std::size_t tmp = num;
num=other.num;
other.num=tmp;
num = other.num;
other.num = tmp;
}

/// Get number of elements in map
Expand All @@ -359,14 +359,14 @@ class sharing_mapt
/// Check if map is empty
bool empty() const
{
return num==0;
return num == 0;
}

/// Clear map
void clear()
{
map.clear();
num=0;
num = 0;
}

/// Check if key is in map
Expand All @@ -376,7 +376,7 @@ class sharing_mapt
/// - Best case: O(1)
bool has_key(const key_type &k) const
{
return get_leaf_node(k)!=nullptr;
return get_leaf_node(k) != nullptr;
}

// views
Expand Down Expand Up @@ -695,8 +695,7 @@ ::iterate(
f(l.get_key(), l.get_value());
}
}
}
while(!stack.empty());
} while(!stack.empty());
}

SHARING_MAPT(std::size_t)
Expand Down Expand Up @@ -907,7 +906,10 @@ SHARING_MAPT(void)::add_item_if_not_shared(
}
}

delta_view.push_back({k, leaf.get_value()});
if(!only_common)
{
delta_view.push_back({k, leaf.get_value()});
}

return;
}
Expand All @@ -920,10 +922,11 @@ SHARING_MAPT(void)::add_item_if_not_shared(
if(equalT()(leaf.get_key(), ip->get_key()))
{
delta_view.push_back({k, leaf.get_value(), ip->get_value()});
return;
}

delta_view.push_back({k, leaf.get_value()});
else if(!only_common)
{
delta_view.push_back({k, leaf.get_value()});
}
Comment on lines +926 to +929
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the same apply in line 909?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I believe so - our comments crossed in the ether 🙂 - but I don't have a case that hits that line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like the build to complete, and then I'll push that change too.


return;
}
Expand Down Expand Up @@ -1113,8 +1116,7 @@ ::get_delta_view(
}
}
}
}
while(!stack.empty());
} while(!stack.empty());
}

SHARING_MAPT2(, delta_viewt)::get_delta_view(
Expand Down Expand Up @@ -1217,7 +1219,7 @@ SHARING_MAPT(void)::erase(const key_type &k)
if(m.size() > 1 || del == nullptr)
{
del = ip;
del_bit=bit;
del_bit = bit;
}

ip = &ip->add_child(bit);
Expand Down