From f0cfe1c85a5d490b149098a4aa60f3a0718c6f22 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 31 Jul 2018 15:32:01 -0700 Subject: [PATCH] PVField::copy() avoid duplication with copyUnchecked() --- src/factory/PVField.cpp | 50 +---------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/src/factory/PVField.cpp b/src/factory/PVField.cpp index bd9a491..8553eec 100644 --- a/src/factory/PVField.cpp +++ b/src/factory/PVField.cpp @@ -187,55 +187,7 @@ void PVField::copy(const PVField& from) if (getField()->getType() != from.getField()->getType()) throw std::invalid_argument("field types do not match"); - switch(getField()->getType()) - { - case scalar: - { - const PVScalar* fromS = static_cast(&from); - PVScalar* toS = static_cast(this); - toS->copy(*fromS); - break; - } - case scalarArray: - { - const PVScalarArray* fromS = static_cast(&from); - PVScalarArray* toS = static_cast(this); - toS->copy(*fromS); - break; - } - case structure: - { - const PVStructure* fromS = static_cast(&from); - PVStructure* toS = static_cast(this); - toS->copy(*fromS); - break; - } - case structureArray: - { - const PVStructureArray* fromS = static_cast(&from); - PVStructureArray* toS = static_cast(this); - toS->copy(*fromS); - break; - } - case union_: - { - const PVUnion* fromS = static_cast(&from); - PVUnion* toS = static_cast(this); - toS->copy(*fromS); - break; - } - case unionArray: - { - const PVUnionArray* fromS = static_cast(&from); - PVUnionArray* toS = static_cast(this); - toS->copy(*fromS); - break; - } - default: - { - throw std::logic_error("PVField::copy unknown type"); - } - } + copyUnchecked(from); } void PVField::copyUnchecked(const PVField& from)