CServerPath CPathCache::Lookup(const tServerCache &serverCache, const CServerPath& source, const wxString subdir) { CSourcePath sourcePath; sourcePath.source = source; sourcePath.subdir = subdir; tServerCacheConstIterator serverIter = serverCache.find(sourcePath); if (serverIter == serverCache.end()) return CServerPath(); return serverIter->second; }
void CPathCache::InvalidatePath(tServerCache & serverCache, CServerPath const& path, wxString const& subdir) { CSourcePath sourcePath; sourcePath.source = path; sourcePath.subdir = subdir; CServerPath target; tServerCacheIterator serverIter = serverCache.find(sourcePath); if (serverIter != serverCache.end()) { target = serverIter->second; serverCache.erase(serverIter); } if (target.empty() && !subdir.empty()) { target = path; if (!target.AddSegment(subdir)) return; } if (!target.empty()) { // Unfortunately O(n), don't know of a faster way. for (auto serverIter = serverCache.begin(); serverIter != serverCache.end(); ) { if (serverIter->second == target || target.IsParentOf(serverIter->second, false)) serverCache.erase(serverIter++); else if (serverIter->first.source == target || target.IsParentOf(serverIter->first.source, false)) serverCache.erase(serverIter++); else ++serverIter; } } }