From cbe66f3360d756503277176dd60c0a3ac9050abb Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 3 Jun 2006 16:33:42 +0000 Subject: Allocate and grow Common::String objects in multiples of 32, and leave at least 16 spare bytes at the end, in case the string grows a little bit. svn-id: r22896 --- common/str.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'common/str.h') diff --git a/common/str.h b/common/str.h index 1e7fa1577b..2961a6dd73 100644 --- a/common/str.h +++ b/common/str.h @@ -32,10 +32,10 @@ namespace Common { class String { protected: - char *_str; - int _len; - int *_refCount; - int _capacity; + char *_str; + int _len; + mutable int *_refCount; + int _capacity; public: #if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__)) @@ -44,7 +44,7 @@ public: static const char *emptyString; #endif - String() : _str(0), _len(0), _capacity(0) { _refCount = new int(1); } + String() : _str(0), _len(0), _refCount(0), _capacity(0) { incRefCount(); } String(const char *str, int len = -1, int capacity = 16); String(const String &str); virtual ~String(); @@ -114,6 +114,7 @@ public: protected: void ensureCapacity(int new_len, bool keep_old); + void incRefCount() const; void decRefCount(); }; -- cgit v1.2.3