diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-02-03 10:48:50 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-02-03 10:48:50 +0000 |
commit | 0f76e648d800d7641b4e6e6decb90949cd680b03 (patch) | |
tree | 611488238f742926286db5ee2e1809cad18353d8 /tools/llvm-nm | |
parent | d9d2f187759d0154574657c195068d367c338473 (diff) |
[Object][Archive] Improve performance.
Improve performance of iterating over children and accessing the member file
buffer by caching the file size and moving code out to the header.
This also makes getBuffer return a StringRef instead of a MemoryBuffer. Both
fixing a memory leak and removing a malloc.
This takes getBuffer from ~10% of the time in lld to unmeasurable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174272 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-nm')
-rw-r--r-- | tools/llvm-nm/llvm-nm.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index 056fd35422..a24aae6061 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -384,7 +384,9 @@ static void DumpSymbolNamesFromFile(std::string &Filename) { OwningPtr<Binary> child; if (i->getAsBinary(child)) { // Try opening it as a bitcode file. - OwningPtr<MemoryBuffer> buff(i->getBuffer()); + OwningPtr<MemoryBuffer> buff; + if (error(i->getMemoryBuffer(buff))) + return; Module *Result = 0; if (buff) Result = ParseBitcodeFile(buff.get(), Context, &ErrorMessage); |