[NUI] use Size2DProperty for GetNaturalSize() instead of local field (#2515)
authorYeongJong Lee <cleanlyj@naver.com>
Thu, 14 Jan 2021 01:43:01 +0000 (10:43 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 19 Jan 2021 05:32:11 +0000 (14:32 +0900)
Since we can take the size value using `Size2DProperty`, we don't need to
save Size2D value in local value.
It will save a bit of memory.

src/Tizen.NUI/src/public/BaseComponents/CustomView.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs

index 88a7d60..1969599 100755 (executable)
@@ -316,7 +316,7 @@ namespace Tizen.NUI.BaseComponents
         /// <since_tizen> 3 </since_tizen>
         public new virtual Size2D GetNaturalSize()
         {
-            return sizeSetExplicitly;  // Returns the size set explicitly on View unless Overridden.
+            return (Size2D)GetValue(Size2DProperty);
         }
 
         /// <summary>
index 930fa1a..a43899e 100755 (executable)
@@ -29,7 +29,6 @@ namespace Tizen.NUI.BaseComponents
     /// <since_tizen> 3 </since_tizen>
     public partial class View : Container, IResourcesProvider
     {
-        internal Size2D sizeSetExplicitly = new Size2D(); // Store size set by API, will be used in place of NaturalSize if not set.
         internal BackgroundExtraData backgroundExtraData;
 
         private bool layoutSet = false;
@@ -827,7 +826,6 @@ namespace Tizen.NUI.BaseComponents
             }
             set
             {
-                sizeSetExplicitly = value;  // Store size set by API, will be used in place of NaturalSize if not set.
                 SetValue(Size2DProperty, value);
 
                 widthPolicy = value.Width;