From: Pete Cooper Date: Fri, 18 Mar 2016 05:04:04 +0000 (+0000) Subject: Always cache resolved paths as it even saves on StringMap lookups. X-Git-Tag: llvmorg-3.9.0-rc1~11480 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=64d075ec07aafab44dd7da884c5434a22dfe728d;p=platform%2Fupstream%2Fllvm.git Always cache resolved paths as it even saves on StringMap lookups. Now that the resolved path cache stores the StringRef's, its best to just always cache the results, even when realpath isn't used. This way we'll still avoid the StringMap hashing and lookup. This also conveniently reorganises this code in a way I need for a future patch. llvm-svn: 263777 --- diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp index 5ac5bd9..d08f30d 100644 --- a/llvm/tools/dsymutil/DwarfLinker.cpp +++ b/llvm/tools/dsymutil/DwarfLinker.cpp @@ -1640,22 +1640,20 @@ PointerIntPair DeclContextTree::getChildDeclContext( File)) { Line = DIE->getAttributeValueAsUnsignedConstant( &U.getOrigUnit(), dwarf::DW_AT_decl_line, 0); -#ifdef HAVE_REALPATH // Cache the resolved paths, because calling realpath is expansive. StringRef ResolvedPath = U.getResolvedPath(FileNum); if (!ResolvedPath.empty()) { FileRef = ResolvedPath; } else { +#ifdef HAVE_REALPATH char RealPath[PATH_MAX + 1]; RealPath[PATH_MAX] = 0; if (::realpath(File.c_str(), RealPath)) File = RealPath; +#endif FileRef = StringPool.internString(File); U.setResolvedPath(FileNum, FileRef); } -#else - FileRef = StringPool.internString(File); -#endif } } }