Reduced code duplication in FString class
Moved resetting of string data to null value into own function
This commit is contained in:
parent
3cefe10818
commit
7d97963005
2 changed files with 12 additions and 11 deletions
|
|
@ -66,8 +66,7 @@ FString::FString (const char *copyStr)
|
|||
{
|
||||
if (copyStr == NULL || *copyStr == '\0')
|
||||
{
|
||||
NullString.RefCount++;
|
||||
Chars = &NullString.Nothing[0];
|
||||
ResetToNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -87,8 +86,7 @@ FString::FString (char oneChar)
|
|||
{
|
||||
if (oneChar == '\0')
|
||||
{
|
||||
NullString.RefCount++;
|
||||
Chars = &NullString.Nothing[0];
|
||||
ResetToNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -220,8 +218,7 @@ FString &FString::operator = (const char *copyStr)
|
|||
if (copyStr == NULL || *copyStr == '\0')
|
||||
{
|
||||
Data()->Release();
|
||||
NullString.RefCount++;
|
||||
Chars = &NullString.Nothing[0];
|
||||
ResetToNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -362,8 +359,7 @@ FString &FString::CopyCStrPart(const char *tail, size_t tailLen)
|
|||
else
|
||||
{
|
||||
Data()->Release();
|
||||
NullString.RefCount++;
|
||||
Chars = &NullString.Nothing[0];
|
||||
ResetToNull();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -373,8 +369,7 @@ void FString::Truncate(size_t newlen)
|
|||
if (newlen == 0)
|
||||
{
|
||||
Data()->Release();
|
||||
NullString.RefCount++;
|
||||
Chars = &NullString.Nothing[0];
|
||||
ResetToNull();
|
||||
}
|
||||
else if (newlen < Len())
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue