Commit f8a3a85d authored by József Gyürüsi's avatar József Gyürüsi
Browse files

[CR #1837502] remove unnecessary counters v_sizeOfHashMaps and v_numberOfHashMaps



Change-Id: Ie76bd529fafb956fe615167d03e44c7b21c3727d
Signed-off-by: József Gyürüsi's avatarJózsef Gyürüsi <jozsef.gyurusi@ericsson.com>
parent d988097f
......@@ -186,7 +186,7 @@ public:
#define ASSERT_VALID_ID(pl_id) \
\
if(pl_id<0){TTCN_error("HashMap Error: pl_id<0");};\
if(pl_id>=v_sizeOfHashMaps){TTCN_error("HashMap Error: pl_id>=v_sizeOfHashMaps");};\
if(pl_id>=(int)v_HashMap.size()){TTCN_error("HashMap Error: pl_id>=v_sizeOfHashMaps");};\
if(v_HashMap[pl_id]==NULL){TTCN_error("HashMap Error: v_HashMap[pl_id]==NULL");};\
......@@ -198,15 +198,11 @@ private:
typedef HashMapType<T,H,F>* HashMapTypePtr;
typedef typename HashMapType<T,H,F>::iterator HashMapTypeIter;
typedef typename HashMapType<T,H,F>::hasher HashMapTypeHasher;
int v_sizeOfHashMaps;
int v_numberOfHashMaps;
NamesHashMapType v_HashNames;
std::vector<HashMapTypePtr> v_HashMap;
std::stack<int> freeSlotsIn_v_HashMap;
public:
HashMapTypeCT(){
v_sizeOfHashMaps = 0;
v_numberOfHashMaps = 0;
}
~HashMapTypeCT(){
NamesHashMapType::iterator Hashmap_Iter;
......@@ -230,22 +226,19 @@ public:
v_HashMap[Hashmap_Iter->second] = NULL;
}
v_HashNames.erase(Hashmap_Iter);
v_numberOfHashMaps--;
Hashmap_Iter = v_HashNames.begin();
}
v_HashMap.clear();
v_sizeOfHashMaps = 0;
v_numberOfHashMaps = 0;
}
inline void assertValid(const INTEGER& pl_id){
if(pl_id<0){TTCN_error("HashMap Error: pl_id<0");};
if(pl_id>=v_sizeOfHashMaps){TTCN_error("HashMap Error: pl_id>=v_sizeOfHashMaps");};
if(pl_id>=(int)v_HashMap.size()){TTCN_error("HashMap Error: pl_id>=v_sizeOfHashMaps");};
if(v_HashMap[pl_id]==NULL){TTCN_error("HashMap Error: v_HashMap[pl_id]==NULL");};
}
inline bool checkValid(const INTEGER& pl_id){
if(pl_id<0){return false;};
if(pl_id>=v_sizeOfHashMaps){return false;};
if(pl_id>=(int)v_HashMap.size()){return false;};
if(v_HashMap[pl_id]==NULL){return false;};
return true;
}
......@@ -268,8 +261,7 @@ public:
}
return -1;
}
v_numberOfHashMaps++;
if(v_numberOfHashMaps<v_sizeOfHashMaps)
if(! freeSlotsIn_v_HashMap.empty())
{
int i = freeSlotsIn_v_HashMap.top();
freeSlotsIn_v_HashMap.pop();
......@@ -280,10 +272,11 @@ public:
}
else
{
v_HashNames[pl_name] = v_sizeOfHashMaps;
int i = v_HashMap.size();
v_HashNames[pl_name] = i;
v_HashMap.push_back(new HashMapType<T,H,F>);
v_HashMap[v_sizeOfHashMaps]->initDebug(pl_name);
return v_sizeOfHashMaps++;
v_HashMap[i]->initDebug(pl_name);
return i;
}
//never reaches
return -1;
......@@ -348,7 +341,6 @@ public:
freeSlotsIn_v_HashMap.push(Hashmap_Iter->second);
}
v_HashNames.erase(Hashmap_Iter);
v_numberOfHashMaps--;
}
void deleteHashMap(
......@@ -377,7 +369,6 @@ public:
v_HashMap[pl_id] = NULL;
freeSlotsIn_v_HashMap.push(pl_id);
}
v_numberOfHashMaps--;
}
void dumpByID (const INTEGER& pl_id)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment