From 8daa9fb8a5ef6244bb98fea54cb078d5d66e5224 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Tue, 2 Oct 2018 13:37:34 +0900 Subject: [PATCH] [enco] Clone Bag if possible (#1718) The current implementation of 'clone' method always tries to clone an object along with its backing bag. With this commit, 'clone' method clones its backing bag only when there is a backing bag for a given object. Signed-off-by: Jonghyun Park --- contrib/enco/core/src/Transforms/Normalize.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/contrib/enco/core/src/Transforms/Normalize.cpp b/contrib/enco/core/src/Transforms/Normalize.cpp index c2d30dc..972a24c 100644 --- a/contrib/enco/core/src/Transforms/Normalize.cpp +++ b/contrib/enco/core/src/Transforms/Normalize.cpp @@ -90,14 +90,16 @@ private: coco::FeatureObject *ShuffleGen::clone(const coco::FeatureObject *oldobj) const { - auto oldbag = oldobj->bag(); - - auto newbag = _module->entity()->bag()->create(oldbag->size()); auto newobj = _module->entity()->object()->create(oldobj->shape()); - - newobj->bag(newbag); newobj->layout(coco::FeatureLayouts::BHWC::create(oldobj->shape())); + if (auto oldbag = oldobj->bag()) + { + // Clone bag only when there is a backing bag for a given feature object + auto newbag = _module->entity()->bag()->create(oldbag->size()); + newobj->bag(newbag); + } + return newobj; } -- 2.7.4