From 46b920b55217b4a048b01de899f6ef55a5dd7168 Mon Sep 17 00:00:00 2001 From: Cheng-Shiun Tsai Date: Thu, 9 Jul 2020 16:58:07 +0100 Subject: [PATCH] Dali::Vector used as file buffer container dali-adator file reader uses Dali::Vector 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dali/public-api/common/dali-vector.h b/dali/public-api/common/dali-vector.h index 9ae40e2..6396028 100755 --- a/dali/public-api/common/dali-vector.h +++ b/dali/public-api/common/dali-vector.h @@ -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 -- 2.7.4