Dali::Vector<char> used as file buffer container 35/238235/6
authorCheng-Shiun Tsai <cheng.tsai@samsung.com>
Thu, 9 Jul 2020 15:58:07 +0000 (16:58 +0100)
committerTsai <cheng.tsai@samsung.com>
Wed, 26 Aug 2020 15:34:59 +0000 (15:34 +0000)
dali-adator file reader uses Dali::Vector<char,true> as the container for data buffer.
However, Dali::Vector::Resize always initialize the element by doing PushBack().
Considering now you need to read a file of 1MB,
Resize() would lead to PushBack() of one byte X one million times,
so that it becomes a vector of 1MB, this is unnecessary waste of CPU time.
We need another method which simply allocates the buffer without initialize the value.
It will help use cases such as MCD Avatar3D / AREmoji where there are a lot of resource files

Change-Id: I03eb723142799cc9ae0f71bc1b35036e1b21cc81

dali/public-api/common/dali-vector.h

index 9ae40e2..6396028 100755 (executable)
@@ -692,6 +692,19 @@ public: // API
   }
 
   /**
+   * @brief Resizes the vector without initializing the data.
+   *
+   * Can be used as a data container for reading whole file content.
+   * @SINCE_1_9.27
+   * @param[in] count Count to resize to
+   */
+  void ResizeUninitialized( SizeType count )
+  {
+    Reserve( count );
+    VectorBase::SetCount( count );
+  }
+
+  /**
    * @brief Resizes the vector. Does not change capacity.
    *
    * @SINCE_1_0.0