Remove object_error::success and use std::error_code() instead
make_error_code(object_error) is slow because object::object_category()
uses a ManagedStatic variable. But the real problem is that the function is
called too frequently. This patch uses std::error_code() instead of
object_error::success. In most cases, we return "success", so this patch
reduces number of function calls to that function.
http://reviews.llvm.org/D10333
llvm-svn: 239409
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index fb91eed..54ed954 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -224,7 +224,7 @@
child_iterator e = child_end();
if (i == e) {
- ec = object_error::success;
+ ec = std::error_code();
return;
}
@@ -254,7 +254,7 @@
SymbolTable = i;
++i;
FirstRegular = i;
- ec = object_error::success;
+ ec = std::error_code();
return;
}
@@ -298,14 +298,14 @@
StringTable = i;
++i;
FirstRegular = i;
- ec = object_error::success;
+ ec = std::error_code();
return;
}
if (Name[0] != '/') {
Format = has64SymTable ? K_MIPS64 : K_GNU;
FirstRegular = i;
- ec = object_error::success;
+ ec = std::error_code();
return;
}
@@ -320,7 +320,7 @@
++i;
if (i == e) {
FirstRegular = i;
- ec = object_error::success;
+ ec = std::error_code();
return;
}
@@ -332,7 +332,7 @@
}
FirstRegular = i;
- ec = object_error::success;
+ ec = std::error_code();
}
Archive::child_iterator Archive::child_begin(bool SkipInternal) const {