Make Actor's name don't use ConstString 37/315237/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 29 Jul 2024 01:38:40 +0000 (10:38 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 29 Jul 2024 01:38:40 +0000 (10:38 +0900)
Since ConstString register into internal string pool
and never be released,
Their might be occured some memory limits if user use randomized name.

Until now, we use raw string comparision at FindChildByName.
So their is no performance issue after this patch.

TODO : How could we resolve same issue for RegisterProperty?

Change-Id: Ia4258d204e986c117f19489a075e3c5afff9fab9
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h
dali/internal/event/actors/actor-parent-impl.cpp
dali/internal/event/actors/actor-parent-impl.h
dali/internal/event/actors/actor-parent.h
dali/public-api/actors/actor.cpp

index 49e2b693363b383c0aaa558259d3fdccd68cacf1..5e1e60408b1fce5e7e21a09b79e25e391a223853 100644 (file)
@@ -396,10 +396,10 @@ const SceneGraph::Node* Actor::CreateNode()
 
 void Actor::SetName(std::string_view name)
 {
-  mName = ConstString(name);
+  mName = name;
 
   // ATTENTION: string for debug purposes is not thread safe.
-  DALI_LOG_SET_OBJECT_STRING(const_cast<SceneGraph::Node*>(&GetNode()), mName.GetCString());
+  DALI_LOG_SET_OBJECT_STRING(const_cast<SceneGraph::Node*>(&GetNode()), mName.c_str());
 }
 
 uint32_t Actor::GetId() const
@@ -1243,7 +1243,7 @@ ActorContainer& Actor::GetChildrenInternal()
   return mParentImpl.GetChildrenInternal();
 }
 
-ActorPtr Actor::FindChildByName(ConstString actorName)
+ActorPtr Actor::FindChildByName(const std::string_view& actorName)
 {
   return mParentImpl.FindChildByName(actorName);
 }
index 9c9985c868b78428aa216bcc92ee43da43f2e9c9..30381ab8fe540a974d419f92a8e3e55696562ff7 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_ACTOR_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -94,7 +94,7 @@ public:
    */
   std::string_view GetName() const
   {
-    return mName.GetStringView();
+    return mName;
   }
 
   /**
@@ -194,7 +194,7 @@ public:
   /**
    * @copydoc Dali::Internal::ActorParent::FindChildByName
    */
-  ActorPtr FindChildByName(ConstString actorName) override;
+  ActorPtr FindChildByName(const std::string_view& actorName) override;
 
   /**
    * @copydoc Dali::Internal::ActorParent::FindChildById
@@ -1984,7 +1984,7 @@ protected:
   Vector3    mTargetScale;       ///< Event-side storage for scale
   Rect<int>  mTouchAreaOffset;   ///< touch area offset (left, right, bottom, top)
 
-  ConstString mName;        ///< Name of the actor
+  std::string mName;        ///< Name of the actor
   uint32_t    mSortedDepth; ///< The sorted depth index. A combination of tree traversal and sibling order.
   int16_t     mDepth;       ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported
 
index 8a03b025bcc899beea18bb642fa01bc23458616e..9ccabff830496a728f0d4e93a06732d8d9e42686 100644 (file)
@@ -170,10 +170,10 @@ ActorPtr ActorParentImpl::GetChildAt(uint32_t index) const
   return ((mChildren) ? (*mChildren)[index] : ActorPtr());
 }
 
-ActorPtr ActorParentImpl::FindChildByName(ConstString actorName)
+ActorPtr ActorParentImpl::FindChildByName(const std::string_view& actorName)
 {
   ActorPtr child = nullptr;
-  if(actorName.GetStringView() == mOwner.GetName())
+  if(actorName == mOwner.GetName())
   {
     child = &mOwner;
   }
index c7fedb26f532628a9e51a41e29519b0da60d7e43..9642b167e02bf72240b047ed4b33f5021deaa203 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef DALI_INTERNAL_ACTOR_PARENT_IMPL_H
 #define DALI_INTERNAL_ACTOR_PARENT_IMPL_H
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use actor file except in compliance with the License.
@@ -80,7 +80,7 @@ public:
   /**
    * @copydoc Dali::Actor::FindChildByName
    */
-  ActorPtr FindChildByName(ConstString actorName) override;
+  ActorPtr FindChildByName(const std::string_view& actorName) override;
 
   /**
    * @copydoc Dali::Actor::FindChildById
index 62fdfbd6f976940f14f8c77212fb5d0c2715719e..dd33718e2219808385fed5d1f163a5dba6c1000d 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef DALI_INTERNAL_ACTOR_PARENT_H
 #define DALI_INTERNAL_ACTOR_PARENT_H
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use actor file except in compliance with the License.
@@ -75,7 +75,7 @@ public:
   /**
    * @copydoc Dali::Actor::FindChildByName
    */
-  virtual ActorPtr FindChildByName(ConstString actorName) = 0;
+  virtual ActorPtr FindChildByName(const std::string_view& actorName) = 0;
 
   /**
    * @copydoc Dali::Actor::FindChildById
index cb5b8e7277acf40f5f6da447637dfa6052cfbe01..6fad66f875d604d6faab390ac0d23b16d9dde66e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -91,7 +91,7 @@ Actor Actor::GetChildAt(uint32_t index) const
 
 Actor Actor::FindChildByName(std::string_view actorName)
 {
-  Internal::ActorPtr child = GetImplementation(*this).FindChildByName(Internal::ConstString(actorName));
+  Internal::ActorPtr child = GetImplementation(*this).FindChildByName(actorName);
   return Actor(child.Get());
 }