+ DALI_ASSERT_DEBUG( mGlyphsPerCharacter.Count() != 0u );
+
+ // Get the total number of characters.
+ const Length totalNumberOfCharacters = ( 0u == mGlyphsToCharacters.Count() ) ? 0u : *( mGlyphsToCharacters.End() - 1u ) + *( mCharactersPerGlyph.End() - 1u ); // Index to the first character + the number of characters that form the last glyph.
+
+ // Whether the current buffer is being updated or is set from scratch.
+ const bool updateCurrentBuffer = numberOfCharacters < totalNumberOfCharacters;
+
+ Vector<GlyphIndex> newCharactersToGlyph;
+ GlyphIndex* charactersToGlyphBuffer = NULL;
+
+ // 1) Reserve some space for the glyph indices to avoid reallocations.
+ if( updateCurrentBuffer )
+ {
+ newCharactersToGlyph.Resize( numberOfCharacters );
+ charactersToGlyphBuffer = newCharactersToGlyph.Begin();
+ }
+ else
+ {
+ mCharactersToGlyph.Resize( numberOfCharacters );
+ charactersToGlyphBuffer = mCharactersToGlyph.Begin() + startIndex;
+ }