From e5ad0f52b33f7c1fc848d5bac8f6642131b44b17 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 25 Jun 2020 15:12:28 -0400 Subject: [PATCH] bpls: Avoid looking up variables and attributes we already have --- source/utils/bpls/bpls.cpp | 8 ++++---- source/utils/bpls/bpls.h | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/source/utils/bpls/bpls.cpp b/source/utils/bpls/bpls.cpp index d4077f5982..0053e5beb0 100644 --- a/source/utils/bpls/bpls.cpp +++ b/source/utils/bpls/bpls.cpp @@ -907,7 +907,7 @@ 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); } } @@ -915,7 +915,7 @@ int doList_vars(core::Engine *fp, core::IO *io) { 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); } } @@ -963,7 +963,7 @@ int doList_vars(core::Engine *fp, core::IO *io) #define declare_template_instantiation(T) \ else if (entry.typeName == helper::GetDataType()) \ { \ - core::Attribute *a = io->InquireAttribute(name); \ + core::Attribute *a = static_cast *>(entry.attr); \ retval = printAttributeValue(fp, io, a); \ } ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_1ARG( @@ -986,7 +986,7 @@ int doList_vars(core::Engine *fp, core::IO *io) #define declare_template_instantiation(T) \ else if (entry.typeName == helper::GetDataType()) \ { \ - core::Variable *v = io->InquireVariable(name); \ + core::Variable *v = static_cast *>(entry.var); \ retval = printVariableInfo(fp, io, v); \ } ADIOS2_FOREACH_STDTYPE_1ARG(declare_template_instantiation) diff --git a/source/utils/bpls/bpls.h b/source/utils/bpls/bpls.h index 66bd7aa8ac..8cdb69b1e0 100644 --- a/source/utils/bpls/bpls.h +++ b/source/utils/bpls/bpls.h @@ -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