Use the same growth strategy in wxArrayString as in wxVector

Remove maximal reallocation size in wxArrayString too, as it was done
for wxVector a commit ago, and increase its size by 100% and not 50%
when it needs to grow.

There is no real reason to use different growth strategies in the two
classes and wxVector one seems to be better.
This commit is contained in:
Vadim Zeitlin
2017-11-19 22:02:26 +01:00
parent d3132b114c
commit abce2a9428

View File

@@ -57,9 +57,6 @@ wxArrayString::wxArrayString(size_t sz, const wxString* a)
#if !wxUSE_STD_CONTAINERS
// size increment = min(50% of current size, ARRAY_MAXSIZE_INCREMENT)
#define ARRAY_MAXSIZE_INCREMENT 4096
#ifndef ARRAY_DEFAULT_INITIAL_SIZE // also defined in dynarray.h
#define ARRAY_DEFAULT_INITIAL_SIZE (16)
#endif
@@ -139,11 +136,8 @@ wxString *wxArrayString::Grow(size_t nIncrement)
else {
// otherwise when it's called for the first time, nIncrement would be 0
// and the array would never be expanded
// add 50% but not too much
size_t ndefIncrement = m_nSize < ARRAY_DEFAULT_INITIAL_SIZE
? ARRAY_DEFAULT_INITIAL_SIZE : m_nSize >> 1;
if ( ndefIncrement > ARRAY_MAXSIZE_INCREMENT )
ndefIncrement = ARRAY_MAXSIZE_INCREMENT;
? ARRAY_DEFAULT_INITIAL_SIZE : m_nSize;
if ( nIncrement < ndefIncrement )
nIncrement = ndefIncrement;
m_nSize += nIncrement;