Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache function return types #7058

Merged
merged 1 commit into from Jan 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CommonTools/Utils/src/MethodInvoker.cc
Expand Up @@ -109,7 +109,7 @@ MethodInvoker::
returnTypeName() const
{
if (isFunction_) {
return method_.finalReturnType().qualifiedName();
return method_.typeName();
}
return member_.typeOf().qualifiedName();
}
Expand Down
2 changes: 1 addition & 1 deletion CommonTools/Utils/src/MethodSetter.cc
Expand Up @@ -79,7 +79,7 @@ push(const string& name, const vector<AnyMethodArgument>& args,
<< "member \"" << mem.first.name()
<< "\" return type is invalid:\n"
<< " return type: \""
<< mem.first.finalReturnType().qualifiedName() << "\"\n";
<< mem.first.typeName() << "\"\n";
}
typeStack_.push_back(retType);
// check for edm::Ref, edm::RefToBase, edm::Ptr
Expand Down
15 changes: 14 additions & 1 deletion FWCore/Utilities/src/FunctionWithDict.cc
Expand Up @@ -8,7 +8,14 @@
#include "TMethod.h"
#include "TMethodArg.h"

#include "tbb/concurrent_unordered_map.h"


namespace edm {
namespace {
typedef tbb::concurrent_unordered_map<TMethod const*, TypeWithDict> Map;
Map returnTypeMap;
}

FunctionWithDict::FunctionWithDict() : function_(nullptr) {
}
Expand All @@ -34,7 +41,13 @@ namespace edm {

TypeWithDict
FunctionWithDict::finalReturnType() const {
return TypeWithDict::byName(function_->GetReturnTypeNormalizedName());
auto const& item = returnTypeMap.find(function_);
if(item != returnTypeMap.end()) {
return item->second;
}
TypeWithDict theType = TypeWithDict::byName(function_->GetReturnTypeNormalizedName());
returnTypeMap.insert(std::make_pair(function_, theType));
return theType;
}

TypeWithDict
Expand Down