projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix undefined variable color to colour
[wxWidgets.git]
/
src
/
common
/
stringimpl.cpp
diff --git
a/src/common/stringimpl.cpp
b/src/common/stringimpl.cpp
index 95d686330143ace1c9ddc08b4d8c4c16448194fe..d0a7165ce747ccd118e478ca051eae38bdce542e 100644
(file)
--- a/
src/common/stringimpl.cpp
+++ b/
src/common/stringimpl.cpp
@@
-42,10
+42,6
@@
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
-#ifdef __SALFORDC__
- #include <clib.h>
-#endif
-
// allocating extra space for each string consumes more memory but speeds up
// the concatenation operations (nLen is the current string's length)
// NB: EXTRA_ALLOC must be >= 0!
// allocating extra space for each string consumes more memory but speeds up
// the concatenation operations (nLen is the current string's length)
// NB: EXTRA_ALLOC must be >= 0!
@@
-115,19
+111,26
@@
extern const wxStringCharType WXDLLIMPEXP_BASE *wxEmptyString = &g_strEmpty.dumm
// ----------------------------------------------------------------------------
// this small class is used to gather statistics for performance tuning
// ----------------------------------------------------------------------------
// this small class is used to gather statistics for performance tuning
+
+// uncomment this to enable gathering of some statistics about wxString
+// efficiency
//#define WXSTRING_STATISTICS
//#define WXSTRING_STATISTICS
+
#ifdef WXSTRING_STATISTICS
class Averager
{
public:
Averager(const wxStringCharType *sz) { m_sz = sz; m_nTotal = m_nCount = 0; }
~Averager()
#ifdef WXSTRING_STATISTICS
class Averager
{
public:
Averager(const wxStringCharType *sz) { m_sz = sz; m_nTotal = m_nCount = 0; }
~Averager()
- { wxPrintf("wxString: average %s = %f\n", m_sz, ((float)m_nTotal)/m_nCount); }
+ {
+ wxPrintf("wxString %s: total = %lu, average = %f\n",
+ m_sz, m_nTotal, ((float)m_nTotal)/m_nCount);
+ }
void Add(size_t n) { m_nTotal += n; m_nCount++; }
private:
void Add(size_t n) { m_nTotal += n; m_nCount++; }
private:
-
size_t
m_nCount, m_nTotal;
+
unsigned long
m_nCount, m_nTotal;
const wxStringCharType *m_sz;
} g_averageLength("allocation size"),
g_averageSummandLength("summand length"),
const wxStringCharType *m_sz;
} g_averageLength("allocation size"),
g_averageSummandLength("summand length"),
@@
-184,7
+187,7
@@
wxStringImpl::wxStringImpl(const_iterator first, const_iterator last)
{
if ( last >= first )
{
{
if ( last >= first )
{
- InitWith(first, 0, last - first);
+ InitWith(first
.GetPtr()
, 0, last - first);
}
else
{
}
else
{
@@
-211,8
+214,8
@@
bool wxStringImpl::AllocBuffer(size_t nLen)
wxASSERT( nLen > 0 );
// make sure that we don't overflow
wxASSERT( nLen > 0 );
// make sure that we don't overflow
- wx
ASSERT
( nLen < (INT_MAX / sizeof(wxStringCharType)) -
-
(sizeof(wxStringData) + EXTRA_ALLOC + 1)
);
+ wx
CHECK
( nLen < (INT_MAX / sizeof(wxStringCharType)) -
+
(sizeof(wxStringData) + EXTRA_ALLOC + 1), false
);
STATISTICS_ADD(Length, nLen);
STATISTICS_ADD(Length, nLen);
@@
-339,6
+342,8
@@
bool wxStringImpl::Alloc(size_t nLen)
wxStringData *pData = GetStringData();
if ( pData->nAllocLength <= nLen ) {
if ( pData->IsEmpty() ) {
wxStringData *pData = GetStringData();
if ( pData->nAllocLength <= nLen ) {
if ( pData->IsEmpty() ) {
+ STATISTICS_ADD(Length, nLen);
+
nLen += EXTRA_ALLOC;
pData = (wxStringData *)
nLen += EXTRA_ALLOC;
pData = (wxStringData *)
@@
-584,7
+589,7
@@
wxStringImpl& wxStringImpl::replace(size_t nStart, size_t nLen,
wxASSERT_MSG( nStart <= lenOld,
_T("index out of bounds in wxStringImpl::replace") );
size_t nEnd = nStart + nLen;
wxASSERT_MSG( nStart <= lenOld,
_T("index out of bounds in wxStringImpl::replace") );
size_t nEnd = nStart + nLen;
- if ( n
End > lenOld
)
+ if ( n
Len > lenOld - nStart
)
{
// nLen may be out of range, as it can be npos, just clump it down
nLen = lenOld - nStart;
{
// nLen may be out of range, as it can be npos, just clump it down
nLen = lenOld - nStart;