aboutsummaryrefslogtreecommitdiff
path: root/common/str.h
diff options
context:
space:
mode:
authorMax Horn2006-06-03 16:33:42 +0000
committerMax Horn2006-06-03 16:33:42 +0000
commitcbe66f3360d756503277176dd60c0a3ac9050abb (patch)
tree210b1e59565bd107799f29887eaf53198e7461ad /common/str.h
parent9b08aefbb318ab1c80f5b4d24a5f0fa741b8996c (diff)
downloadscummvm-rg350-cbe66f3360d756503277176dd60c0a3ac9050abb.tar.gz
scummvm-rg350-cbe66f3360d756503277176dd60c0a3ac9050abb.tar.bz2
scummvm-rg350-cbe66f3360d756503277176dd60c0a3ac9050abb.zip
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
Diffstat (limited to 'common/str.h')
-rw-r--r--common/str.h11
1 files changed, 6 insertions, 5 deletions
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();
};