Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit ee3f9cf

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Use C++17 has_include for unordered map/set
Belonging to [master]: - #2234
1 parent 88c4d61 commit ee3f9cf

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Compiler/runtime/systemimplmisc.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,20 @@
44

55
#include <string>
66
#include <stack>
7+
8+
#if !defined(__has_include)
9+
#define __has_include(X) 0
10+
#endif
11+
12+
#if __has_include(<unordered_set>) && __has_include(<unordered_map>)
13+
#include <unordered_set>
714
#include <unordered_map>
15+
#else
16+
#define unordered_set set
17+
#define unordered_map map
18+
#include <set>
19+
#include <map>
20+
#endif
821

922
using namespace std;
1023

@@ -60,7 +73,7 @@ double SystemImpl__getSizeOfData(void *data, double *raw_size_res, double *nonsh
6073
size_t sz=0, raw_sz=0, nonshared_str_sz=0;
6174
std::unordered_map<void*,void*> handled;
6275
std::stack<void*> work;
63-
std::unordered_map<std::string, void*> strings;
76+
std::unordered_set<std::string> strings;
6477
work.push(data);
6578
while (!work.empty()) {
6679
void *item = work.top();
@@ -90,7 +103,7 @@ double SystemImpl__getSizeOfData(void *data, double *raw_size_res, double *nonsh
90103
if (strings.find(s) != strings.end()) {
91104
nonshared_str_sz += actual;
92105
} else {
93-
strings[s] = item;
106+
strings.insert(s);
94107
}
95108
raw_sz += t;
96109
sz += actual;

0 commit comments

Comments
 (0)