Skip to content

Commit c47159d

Browse files
committed
Fix early rejection
1 parent f97e093 commit c47159d

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

simplecpp.cpp

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,33 +3017,46 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::tryload(const F
30173017

30183018
std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::get(const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader, std::vector<std::string> &filenames, simplecpp::OutputList *outputList)
30193019
{
3020-
#define TRYLOAD(path) \
3021-
{ \
3022-
const auto ins = mNameMap.insert(std::make_pair(path, nullptr)); \
3023-
if (ins.second) { \
3024-
const auto load = tryload(ins.first, dui, filenames, outputList); \
3025-
if (load.first != nullptr) \
3026-
return load; \
3027-
} \
3028-
else { \
3029-
return std::make_pair(ins.first->second, false); \
3030-
} \
3031-
}
3032-
30333020
if (isAbsolutePath(header)) {
3034-
TRYLOAD(simplecpp::simplifyPath(header))
3021+
const auto ins = mNameMap.insert(std::make_pair(simplecpp::simplifyPath(header), nullptr));
3022+
3023+
if (ins.second) {
3024+
const auto load = tryload(ins.first, dui, filenames, outputList);
3025+
if (load.first != nullptr)
3026+
return load;
3027+
}
3028+
else {
3029+
return std::make_pair(ins.first->second, false);
3030+
}
3031+
30353032
return std::make_pair(nullptr, false);
30363033
}
30373034

30383035
if (!systemheader) {
3039-
TRYLOAD(simplecpp::simplifyPath(dirPath(sourcefile) + header))
3036+
const auto ins = mNameMap.insert(std::make_pair(simplecpp::simplifyPath(dirPath(sourcefile) + header), nullptr));
3037+
3038+
if (ins.second) {
3039+
const auto load = tryload(ins.first, dui, filenames, outputList);
3040+
if (load.first != nullptr)
3041+
return load;
3042+
}
3043+
else if (ins.first->second != nullptr) {
3044+
return std::make_pair(ins.first->second, false);
3045+
}
30403046
}
30413047

30423048
for (const auto &includePath : dui.includePaths) {
3043-
TRYLOAD(simplecpp::simplifyPath(includePath + "/" + header))
3044-
}
3049+
const auto ins = mNameMap.insert(std::make_pair(simplecpp::simplifyPath(includePath + "/" + header), nullptr));
30453050

3046-
#undef TRYLOAD
3051+
if (ins.second) {
3052+
const auto load = tryload(ins.first, dui, filenames, outputList);
3053+
if (load.first != nullptr)
3054+
return load;
3055+
}
3056+
else if (ins.first->second != nullptr) {
3057+
return std::make_pair(ins.first->second, false);
3058+
}
3059+
}
30473060

30483061
return std::make_pair(nullptr, false);
30493062
}

0 commit comments

Comments
 (0)