/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Actor& child,
uint32_t order)
{
- if(mChildren)
+ if(mChildren && !mChildren->empty())
{
uint32_t currentOrder = GetSiblingOrderOfChild(child);
if(order != currentOrder)
uint32_t ActorParentImpl::GetSiblingOrderOfChild(const Actor& child) const
{
uint32_t order = 0;
- if(mChildren)
+ if(mChildren && !mChildren->empty())
{
for(std::size_t i = 0; i < mChildren->size(); ++i)
{
void ActorParentImpl::RaiseChild(Actor& child)
{
bool changed = false;
- if(mChildren && mChildren->back() != &child) // If not already at end
+ if(mChildren && !mChildren->empty() && mChildren->back() != &child) // If not already at end
{
- for(std::size_t i = 0; i < mChildren->size(); ++i)
+ for(std::size_t i = 0; i + 1 < mChildren->size(); ++i)
{
if((*mChildren)[i] == &child)
{
// Swap with next
- ActorPtr next = (*mChildren)[i + 1];
+ ActorPtr next = std::move((*mChildren)[i + 1]);
(*mChildren)[i + 1] = &child;
- (*mChildren)[i] = next;
+ (*mChildren)[i] = std::move(next);
changed = true;
break;
}
void ActorParentImpl::LowerChild(Actor& child)
{
bool changed = false;
- if(mChildren && mChildren->front() != &child) // If not already at beginning
+ if(mChildren && !mChildren->empty() && mChildren->front() != &child) // If not already at beginning
{
for(std::size_t i = 1; i < mChildren->size(); ++i)
{
if((*mChildren)[i] == &child)
{
// Swap with previous
- ActorPtr previous = (*mChildren)[i - 1];
+ ActorPtr previous = std::move((*mChildren)[i - 1]);
(*mChildren)[i - 1] = &child;
- (*mChildren)[i] = previous;
+ (*mChildren)[i] = std::move(previous);
changed = true;
break;
}
void ActorParentImpl::RaiseChildToTop(Actor& child)
{
bool changed = false;
- if(mChildren && mChildren->back() != &child) // If not already at end
+ if(mChildren && !mChildren->empty() && mChildren->back() != &child) // If not already at end
{
auto iter = std::find(mChildren->begin(), mChildren->end(), &child);
if(iter != mChildren->end())
void ActorParentImpl::LowerChildToBottom(Actor& child)
{
bool changed = false;
- if(mChildren && mChildren->front() != &child) // If not already at bottom,
+ if(mChildren && !mChildren->empty() && mChildren->front() != &child) // If not already at bottom,
{
ActorPtr childPtr(&child); // ensure actor remains referenced.
void ActorParentImpl::RaiseChildAbove(Actor& child, Actor& target)
{
bool raised = false;
- if(mChildren && mChildren->back() != &child && target.GetParent() == child.GetParent()) // If not already at top
+ if(mChildren && !mChildren->empty() && mChildren->back() != &child && target.GetParent() == child.GetParent()) // If not already at top
{
ActorPtr childPtr(&child); // ensure actor actor remains referenced.
bool lowered = false;
// If not already at bottom
- if(mChildren && mChildren->front() != &child && target.GetParent() == child.GetParent())
+ if(mChildren && !mChildren->empty() && mChildren->front() != &child && target.GetParent() == child.GetParent())
{
ActorPtr childPtr(&child); // ensure actor actor remains referenced.
{
std::string uniqueTypeName = DemangleClassName(theTypeInfo.name());
- return Register(uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit);
+ return Register(std::move(uniqueTypeName), baseTypeInfo, createInstance, callCreateOnInit);
}
std::string TypeRegistry::Register(const std::type_info& theTypeInfo,
{
std::string uniqueTypeName = DemangleClassName(theTypeInfo.name());
- return Register(uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit, defaultProperties, defaultPropertyCount);
+ return Register(std::move(uniqueTypeName), baseTypeInfo, createInstance, callCreateOnInit, defaultProperties, defaultPropertyCount);
}
std::string TypeRegistry::Register(std::string uniqueTypeName,