Browse Source

Remove useless `ConstFrom...()` text methods

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
9b6dbfa6bd
  1. 59
      sources/Text/BaseText.uc
  2. BIN
      sources/Text/Tests/TEST_Text.uc
  3. 21
      sources/Text/TextAPI.uc

59
sources/Text/BaseText.uc

@ -198,65 +198,6 @@ protected final function ReformatRange(
NormalizeFormatting();
}
/**
* Static method for creating an immutable `Text` object from (plain) `string`.
*
* It is preferred to use `TextAPI` methods for creating `Text` instances.
*
* @param source Plain `string` to convert into `Text`.
* @return `Text` instance (guaranteed to be not `none`) that stores contents
* of `source` if treated as a plain `string`.
*/
public static final function Text ConstFromPlainString(string source)
{
local MutableText builder;
local Text result;
builder = MutableText(__().memory.Allocate(class'MutableText'));
result = builder.AppendString(source).Copy();
builder.FreeSelf();
return result;
}
/**
* Static method for creating an immutable `Text` object from
* (colored) `string`.
*
* It is preferred to use `TextAPI` methods for creating `Text` instances.
*
* @param source Colored `string` to convert into `Text`.
* @return `Text` instance (guaranteed to be not `none`) that stores contents
* of `source` if treated as a colored `string`.
*/
public static final function Text ConstFromColoredString(string source)
{
local MutableText builder;
local Text result;
builder = MutableText(__().memory.Allocate(class'MutableText'));
result = builder.AppendColoredString(source).Copy();
builder.FreeSelf();
return result;
}
/**
* Static method for creating an immutable `Text` object from
* (formatted) `string`.
*
* It is preferred to use `TextAPI` methods for creating `Text` instances.
*
* @param source Formatted `string` to convert into `Text`.
* @return `Text` instance (guaranteed to be not `none`) that stores contents
* of `source` if treated as a formatted `string`.
*/
public static final function Text ConstFromFormattedString(string source)
{
local MutableText builder;
local Text result;
builder = MutableText(__().memory.Allocate(class'MutableText'));
result = builder.AppendFormattedString(source).Copy();
builder.FreeSelf();
return result;
}
/**
* Makes an immutable copy (`class'Text'`) of the caller `BaseText`.
*

BIN
sources/Text/Tests/TEST_Text.uc

Binary file not shown.

21
sources/Text/TextAPI.uc

@ -665,7 +665,12 @@ public final function MutableText Empty()
*/
public final function Text FromString(string source)
{
return class'Text'.static.ConstFromPlainString(source);
local MutableText builder;
local Text result;
builder = MutableText(_.memory.Allocate(class'MutableText'));
result = builder.AppendString(source).Copy();
builder.FreeSelf();
return result;
}
/**
@ -695,7 +700,12 @@ public final function MutableText FromStringM(string source)
*/
public final function Text FromColoredString(string source)
{
return class'Text'.static.ConstFromColoredString(source);
local MutableText builder;
local Text result;
builder = MutableText(_.memory.Allocate(class'MutableText'));
result = builder.AppendColoredString(source).Copy();
builder.FreeSelf();
return result;
}
/**
@ -725,7 +735,12 @@ public final function MutableText FromColoredStringM(string source)
*/
public final function Text FromFormattedString(string source)
{
return class'Text'.static.ConstFromFormattedString(source);
local MutableText builder;
local Text result;
builder = MutableText(_.memory.Allocate(class'MutableText'));
result = builder.AppendFormattedString(source).Copy();
builder.FreeSelf();
return result;
}
/**

Loading…
Cancel
Save