Skip to content

Commit

Permalink
bpls: Avoid looking up variables and attributes we already have
Browse files Browse the repository at this point in the history
  • Loading branch information
bradking committed Jul 6, 2020
1 parent 7ebe887 commit e5ad0f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 4 additions & 4 deletions source/utils/bpls/bpls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,15 +907,15 @@ int doList_vars(core::Engine *fp, core::IO *io)
{
for (const auto &vpair : variables)
{
Entry e(true, vpair.second->m_Type);
Entry e(vpair.second->m_Type, vpair.second.get());
entries.emplace(vpair.first, e);
}
}
if (listattrs)
{
for (const auto &apair : attributes)
{
Entry e(false, apair.second->m_Type);
Entry e(apair.second->m_Type, apair.second.get());
entries.emplace(apair.first, e);
}
}
Expand Down Expand Up @@ -963,7 +963,7 @@ int doList_vars(core::Engine *fp, core::IO *io)
#define declare_template_instantiation(T) \
else if (entry.typeName == helper::GetDataType<T>()) \
{ \
core::Attribute<T> *a = io->InquireAttribute<T>(name); \
core::Attribute<T> *a = static_cast<core::Attribute<T> *>(entry.attr); \
retval = printAttributeValue(fp, io, a); \
}
ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_1ARG(
Expand All @@ -986,7 +986,7 @@ int doList_vars(core::Engine *fp, core::IO *io)
#define declare_template_instantiation(T) \
else if (entry.typeName == helper::GetDataType<T>()) \
{ \
core::Variable<T> *v = io->InquireVariable<T>(name); \
core::Variable<T> *v = static_cast<core::Variable<T> *>(entry.var); \
retval = printVariableInfo(fp, io, v); \
}
ADIOS2_FOREACH_STDTYPE_1ARG(declare_template_instantiation)
Expand Down
16 changes: 14 additions & 2 deletions source/utils/bpls/bpls.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,21 @@ namespace utils

struct Entry
{
bool isVar;
DataType typeName;
Entry(bool b, DataType type) : isVar(b), typeName(type) {}
bool isVar;
union
{
core::VariableBase *var;
core::AttributeBase *attr;
};
Entry(DataType type, core::VariableBase *v)
: typeName(type), isVar(true), var(v)
{
}
Entry(DataType type, core::AttributeBase *a)
: typeName(type), isVar(false), attr(a)
{
}
};

// how to print one data item of an array
Expand Down

0 comments on commit e5ad0f5

Please sign in to comment.