[Scummvm-cvs-logs] SF.net SVN: scummvm: [22834] scummvm/trunk/common
sev at users.sourceforge.net
sev at users.sourceforge.net
Fri Jun 2 15:00:55 CEST 2006
Revision: 22834
Author: sev
Date: 2006-06-02 06:00:27 -0700 (Fri, 02 Jun 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=22834&view=rev
Log Message:
-----------
Allocate minimum 16 bytes on String(str) call. Reduces 2.500 malloc() calls
on startup
Modified Paths:
--------------
scummvm/trunk/common/str.cpp
scummvm/trunk/common/str.h
Modified: scummvm/trunk/common/str.cpp
===================================================================
--- scummvm/trunk/common/str.cpp 2006-06-02 12:57:09 UTC (rev 22833)
+++ scummvm/trunk/common/str.cpp 2006-06-02 13:00:27 UTC (rev 22834)
@@ -32,8 +32,8 @@
const char *String::emptyString = "";
#endif
-String::String(const char *str, int len)
- : _str(0), _len(0) {
+String::String(const char *str, int len, int capacity)
+: _str(0), _len(0) {
_refCount = new int(1);
@@ -42,6 +42,9 @@
_capacity = _len = len;
else
_capacity = _len = strlen(str);
+
+ _capacity = MAX(capacity, _capacity);
+
_str = (char *)calloc(1, _capacity+1);
memcpy(_str, str, _len);
_str[_len] = 0;
Modified: scummvm/trunk/common/str.h
===================================================================
--- scummvm/trunk/common/str.h 2006-06-02 12:57:09 UTC (rev 22833)
+++ scummvm/trunk/common/str.h 2006-06-02 13:00:27 UTC (rev 22834)
@@ -45,7 +45,7 @@
#endif
String() : _str(0), _len(0), _capacity(0) { _refCount = new int(1); }
- String(const char *str, int len = -1);
+ String(const char *str, int len = -1, int capacity = 16);
String(const String &str);
virtual ~String();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list