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
Depends on https://review.tizen.org/gerrit/#/c/platform/core/uifw/dali-core/+/238235/
Change-Id: I560ec768a61e3b41c88775397a87f692f3342d54
{
fseek( file, 0, SEEK_END );
length = ftell( file );
- memblock.Resize( length + 1 ); // 1 for extra zero at the end
+ //Dali::Vector.Resize would lead to calling PushBack for each byte, waste of CPU resource
+ memblock.ResizeUninitialized( length + 1 );
+ //put last byte as 0, in case this is a text file without null-terminator
+ memblock[length] = 0;
char* buffer = &memblock[0];
fseek( file, 0, SEEK_SET );