mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-26 23:05:38 +00:00
* Cleanup: Remove leftover comments from str.cpp.
This commit is contained in:
parent
6d0e81763b
commit
704113577b
1 changed files with 6 additions and 93 deletions
|
|
@ -264,8 +264,6 @@ class String::StringData : protected StringDataImpl
|
|||
mLength = length;
|
||||
mIsInterned = interned;
|
||||
|
||||
// mLength is initialized by operator new()
|
||||
|
||||
if( data )
|
||||
{
|
||||
dMemcpy( mData, data, sizeof( StringChar ) * mLength );
|
||||
|
|
@ -289,26 +287,18 @@ class String::StringData : protected StringDataImpl
|
|||
|
||||
static StringData* Create(const StringChar* data, U32 len, bool interned = false)
|
||||
{
|
||||
void* memory = dMalloc(sizeof(StringData) + sizeof(StringChar) * len);
|
||||
StringData* result = new(memory) StringData(data, len, interned);
|
||||
return result;
|
||||
void* memory = dMalloc(sizeof(StringData) + sizeof(StringChar) * len);
|
||||
StringData* result = new(memory) StringData(data, len, interned);
|
||||
return result;
|
||||
}
|
||||
|
||||
static StringData* Create(const StringChar* data, U32 len, DataChunker& chunker, bool interned = false)
|
||||
{
|
||||
// StringData *str = static_cast<StringData*>( chunker.alloc( size + len * sizeof(StringChar) ) );
|
||||
|
||||
// str->mLength = len;
|
||||
|
||||
void* memory = chunker.alloc( sizeof(StringData) + len * sizeof(StringChar)); //dMalloc(sizeof(StringData) + sizeof(Stringchar) * len);
|
||||
StringData* result = new(memory) StringData(data, len, interned);
|
||||
return result;
|
||||
void* memory = chunker.alloc( sizeof(StringData) + len * sizeof(StringChar));
|
||||
StringData* result = new(memory) StringData(data, len, interned);
|
||||
return result;
|
||||
}
|
||||
|
||||
// void* operator new(size_t size, U32 len);
|
||||
// void* operator new( size_t size, U32 len, DataChunker& chunker );
|
||||
// void operator delete(void *);
|
||||
|
||||
bool isShared() const
|
||||
{
|
||||
return ( mRefCount > 1 );
|
||||
|
|
@ -513,57 +503,6 @@ DefineEngineFunction( dumpStringMemStats, void, (), , "()"
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
void* String::StringData::operator new( size_t size, U32 len )
|
||||
{
|
||||
AssertFatal( len != 0, "String::StringData::operator new() - string must not be empty" );
|
||||
StringData *str = static_cast<StringData*>( dMalloc( size + len * sizeof(StringChar) ) );
|
||||
|
||||
str->mLength = len;
|
||||
|
||||
#ifdef TORQUE_DEBUG
|
||||
dFetchAndAdd( sgStringMemBytes, size + len * sizeof(StringChar) );
|
||||
dFetchAndAdd( sgStringInstances, 1 );
|
||||
#endif
|
||||
|
||||
return str;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void String::StringData::operator delete(void *ptr)
|
||||
{
|
||||
StringData* sub = static_cast<StringData *>(ptr);
|
||||
AssertFatal( sub->mRefCount == 0, "StringData::delete() - invalid refcount" );
|
||||
|
||||
#ifdef TORQUE_DEBUG
|
||||
dFetchAndAdd( sgStringMemBytes, U32( -( S32( sizeof( StringData ) + sub->mLength * sizeof(StringChar) ) ) ) );
|
||||
dFetchAndAdd( sgStringInstances, U32( -1 ) );
|
||||
#endif
|
||||
|
||||
dFree( ptr );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void* String::StringData::operator new( size_t size, U32 len, DataChunker& chunker )
|
||||
{
|
||||
AssertFatal( len != 0, "String::StringData::operator new() - string must not be empty" );
|
||||
StringData *str = static_cast<StringData*>( chunker.alloc( size + len * sizeof(StringChar) ) );
|
||||
|
||||
str->mLength = len;
|
||||
|
||||
#ifdef TORQUE_DEBUG
|
||||
dFetchAndAdd( sgStringMemBytes, size + len * sizeof(StringChar) );
|
||||
dFetchAndAdd( sgStringInstances, 1 );
|
||||
#endif
|
||||
|
||||
return str;
|
||||
}
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
String::String()
|
||||
{
|
||||
PROFILE_SCOPE(String_default_constructor);
|
||||
|
|
@ -583,7 +522,6 @@ String::String(const StringChar *str)
|
|||
if( str && *str )
|
||||
{
|
||||
U32 len = dStrlen(str);
|
||||
// _string = new ( len ) StringData( str );
|
||||
_string = StringData::Create(str, len);
|
||||
}
|
||||
else
|
||||
|
|
@ -648,8 +586,6 @@ String String::intern() const
|
|||
// Create new.
|
||||
|
||||
StringData* data = StringData::Create(c_str(), length(), sInternTable->mChunker, true);
|
||||
|
||||
//StringData* data = new ( length(), sInternTable->mChunker ) StringData( c_str(), true );
|
||||
iter = sInternTable->insertUnique( data, data );
|
||||
|
||||
return ( *iter ).value;
|
||||
|
|
@ -740,7 +676,6 @@ String& String::operator=(StringChar c)
|
|||
{
|
||||
_string->release();
|
||||
|
||||
//_string = new ( 2 ) StringData( 0 );
|
||||
_string = StringData::Create(NULL, 2);
|
||||
_string->utf8()[ 0 ] = c;
|
||||
_string->utf8()[ 1 ] = '\0';
|
||||
|
|
@ -752,7 +687,6 @@ String& String::operator+=(StringChar c)
|
|||
{
|
||||
// Append the given string into a new string
|
||||
U32 len = _string->getLength();
|
||||
// StringData* sub = new ( len + 1 ) StringData( NULL );
|
||||
StringData* sub = StringData::Create(NULL, len + 1);
|
||||
|
||||
copy( sub->utf8(), _string->utf8(), len );
|
||||
|
|
@ -780,7 +714,6 @@ String& String::operator=(const StringChar *str)
|
|||
if (str && *str)
|
||||
{
|
||||
U32 len = dStrlen(str);
|
||||
// _string = new ( len ) StringData( str );
|
||||
_string = StringData::Create(str, len);
|
||||
}
|
||||
else
|
||||
|
|
@ -815,7 +748,6 @@ String& String::operator+=(const StringChar *src)
|
|||
sub = StringData::Empty();
|
||||
else
|
||||
{
|
||||
// sub = new ( newlen ) StringData( NULL );
|
||||
sub = StringData::Create(NULL, newlen);
|
||||
|
||||
copy(sub->utf8(),_string->utf8(),lena);
|
||||
|
|
@ -843,7 +775,6 @@ String& String::operator+=(const String &src)
|
|||
sub = StringData::Empty();
|
||||
else
|
||||
{
|
||||
//sub = new ( newlen ) StringData( NULL );
|
||||
sub = StringData::Create(NULL, newlen);
|
||||
|
||||
copy(sub->utf8(),_string->utf8(),lena);
|
||||
|
|
@ -870,7 +801,6 @@ String operator+(const String &a, const String &b)
|
|||
U32 lena = a.length();
|
||||
U32 lenb = b.length();
|
||||
|
||||
//String::StringData *sub = new ( lena + lenb ) String::StringData( NULL );
|
||||
String::StringData* sub = String::StringData::Create(NULL, lena + lenb);
|
||||
|
||||
String::copy(sub->utf8(),a._string->utf8(),lena);
|
||||
|
|
@ -884,7 +814,6 @@ String operator+(const String &a, StringChar c)
|
|||
//PROFILE_SCOPE( String_String_plus_Char );
|
||||
|
||||
U32 lena = a.length();
|
||||
// String::StringData *sub = new ( lena + 1 ) String::StringData( NULL );
|
||||
String::StringData* sub = String::StringData::Create(NULL, lena + 1);
|
||||
|
||||
String::copy(sub->utf8(),a._string->utf8(),lena);
|
||||
|
|
@ -900,7 +829,6 @@ String operator+(StringChar c, const String &a)
|
|||
//PROFILE_SCOPE( String_Char_plus_String );
|
||||
|
||||
U32 lena = a.length();
|
||||
// String::StringData *sub = new ( lena + 1 ) String::StringData( NULL );
|
||||
String::StringData* sub = String::StringData::Create(NULL, lena + 1);
|
||||
|
||||
String::copy(sub->utf8() + 1,a._string->utf8(),lena + 1);
|
||||
|
|
@ -924,7 +852,6 @@ String operator+(const String &a, const StringChar *b)
|
|||
if( !lenb )
|
||||
return a;
|
||||
|
||||
// String::StringData *sub = new ( lena + lenb ) String::StringData( NULL );
|
||||
String::StringData* sub = String::StringData::Create(NULL, lena + lenb);
|
||||
|
||||
String::copy(sub->utf8(),a._string->utf8(),lena);
|
||||
|
|
@ -947,7 +874,6 @@ String operator+(const StringChar *a, const String &b)
|
|||
|
||||
U32 lenb = b.length();
|
||||
|
||||
//String::StringData* sub = new ( lena + lenb ) String::StringData( NULL );
|
||||
String::StringData* sub = String::StringData::Create(NULL, lena + lenb);
|
||||
|
||||
String::copy(sub->utf8(),a,lena);
|
||||
|
|
@ -1157,7 +1083,6 @@ String& String::insert(SizeType pos, const StringChar *str, SizeType len)
|
|||
sub = StringData::Empty();
|
||||
else
|
||||
{
|
||||
// sub = new ( newlen ) StringData( NULL );
|
||||
sub = StringData::Create(NULL, newlen);
|
||||
|
||||
String::copy(sub->utf8(),_string->utf8(),pos);
|
||||
|
|
@ -1187,7 +1112,6 @@ String& String::erase(SizeType pos, SizeType len)
|
|||
sub = StringData::Empty();
|
||||
else
|
||||
{
|
||||
// sub = new ( newlen ) StringData( NULL );
|
||||
sub = StringData::Create(NULL, newlen);
|
||||
|
||||
if (pos > 0)
|
||||
|
|
@ -1218,7 +1142,6 @@ String& String::replace(SizeType pos, SizeType len, const StringChar *str)
|
|||
sub = StringData::Empty();
|
||||
else
|
||||
{
|
||||
// sub = new ( newlen ) StringData( NULL );
|
||||
sub = StringData::Create(NULL, newlen);
|
||||
|
||||
String::copy(sub->utf8(),_string->utf8(), pos);
|
||||
|
|
@ -1250,7 +1173,6 @@ String& String::replace( StringChar c1, StringChar c2 )
|
|||
{
|
||||
if( !foundReplacement )
|
||||
{
|
||||
//sub = new ( length() ) StringData( _string->utf8() );
|
||||
sub = StringData::Create(_string->utf8(), length());
|
||||
|
||||
c = &sub->utf8()[ c - _string->utf8() ];
|
||||
|
|
@ -1306,7 +1228,6 @@ String &String::replace(const String &s1, const String &s2)
|
|||
sub = StringData::Empty();
|
||||
else
|
||||
{
|
||||
//sub = new (newSize - 1 ) StringData( NULL );
|
||||
sub = StringData::Create(NULL, newSize - 1);
|
||||
|
||||
// Now assemble the new string from the pieces of the old...
|
||||
|
|
@ -1375,8 +1296,6 @@ String String::substr(SizeType pos, SizeType len) const
|
|||
else
|
||||
sub = StringData::Create(_string->utf8() + pos, len);
|
||||
|
||||
//sub = new ( len ) StringData( _string->utf8() + pos );
|
||||
|
||||
return sub;
|
||||
}
|
||||
|
||||
|
|
@ -1406,8 +1325,6 @@ String String::trim() const
|
|||
else
|
||||
sub = StringData::Create(start, len);
|
||||
|
||||
//sub = new ( len ) StringData( start );
|
||||
|
||||
return sub;
|
||||
}
|
||||
|
||||
|
|
@ -1623,7 +1540,6 @@ String String::VToString(const char* str, va_list args)
|
|||
sub = StringData::Empty();
|
||||
else
|
||||
{
|
||||
//sub = new ( len ) StringData( NULL );
|
||||
sub = StringData::Create(NULL, len);
|
||||
|
||||
format.copy( sub->utf8() );
|
||||
|
|
@ -1641,7 +1557,6 @@ String String::SpanToString(const char *start, const char *end)
|
|||
AssertFatal( end > start, "Invalid arguments to String::SpanToString - end is before start" );
|
||||
|
||||
U32 len = U32(end - start);
|
||||
//StringData* sub = new ( len ) StringData( start );
|
||||
String::StringData* sub = StringData::Create(start, len);
|
||||
|
||||
return sub;
|
||||
|
|
@ -1652,7 +1567,6 @@ String String::ToLower(const String &string)
|
|||
if ( string.isEmpty() )
|
||||
return String();
|
||||
|
||||
//StringData* sub = new ( string.length() ) StringData( string );
|
||||
String::StringData* sub = StringData::Create(string, string.length());
|
||||
|
||||
dStrlwr( sub->utf8() );
|
||||
|
|
@ -1665,7 +1579,6 @@ String String::ToUpper(const String &string)
|
|||
if ( string.isEmpty() )
|
||||
return String();
|
||||
|
||||
// StringData* sub = new ( string.length() ) StringData( string );
|
||||
String::StringData* sub = StringData::Create(string, string.length());
|
||||
|
||||
dStrupr( sub->utf8() );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue