[CR #1837502] remove unnecessary counters v_sizeOfHashMaps and v_numberOfHashMaps
Change-Id: Ie76bd529fafb956fe615167d03e44c7b21c3727d
Signed-off-by: József Gyürüsi <jozsef.gyurusi@ericsson.com>
diff --git a/src/HashMap/EPTF_CLL_HashMap_ExternalFunctions.hh b/src/HashMap/EPTF_CLL_HashMap_ExternalFunctions.hh
index 71bbc46..e42d219 100644
--- a/src/HashMap/EPTF_CLL_HashMap_ExternalFunctions.hh
+++ b/src/HashMap/EPTF_CLL_HashMap_ExternalFunctions.hh
@@ -186,7 +186,7 @@
#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 @@
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 @@
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 @@
}
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 @@
}
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 @@
freeSlotsIn_v_HashMap.push(Hashmap_Iter->second);
}
v_HashNames.erase(Hashmap_Iter);
- v_numberOfHashMaps--;
}
void deleteHashMap(
@@ -377,7 +369,6 @@
v_HashMap[pl_id] = NULL;
freeSlotsIn_v_HashMap.push(pl_id);
}
- v_numberOfHashMaps--;
}
void dumpByID (const INTEGER& pl_id)