MCPcopy Create free account
hub / github.com/AliveToolkit/alive2 / merge

Method merge

tools/transform.cpp:932–959  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

930 }
931
932 void merge(const CountMemBlock &other) {
933 // if LHS has x more non-locals than RHS, then it gets to keep the first
934 // x cached accessed pointers, as for sure we have accessed all common
935 // pointers plus x extra pointers if we go through the LHS path
936 unsigned delta = num_nonlocals - other.num_nonlocals;
937 bool lhs_larger = num_nonlocals >= other.num_nonlocals;
938 if (!lhs_larger) {
939 num_nonlocals = other.num_nonlocals;
940 delta = -delta;
941 }
942
943 for (auto I = nonlocal_cache.begin(); I != nonlocal_cache.end(); ) {
944 if (other.nonlocal_cache.count(*I)) {
945 ++I;
946 } else if (delta > 0) {
947 ++I;
948 --delta;
949 } else {
950 I = nonlocal_cache.erase(I);
951 }
952 }
953
954 for (auto &e : other.nonlocal_cache) {
955 if (delta > 0 && nonlocal_cache.emplace(e).second) {
956 --delta;
957 }
958 }
959 }
960};
961}
962

Callers

nothing calls this directly

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected