Remove unused String::Substring

This commit is contained in:
Ted John 2018-02-06 18:02:58 +00:00
parent b6823242b6
commit 0fc0d16e85
2 changed files with 0 additions and 50 deletions

View File

@ -342,46 +342,6 @@ namespace String
return DiscardUse(ptr, String::Duplicate(replacement));
}
utf8 * Substring(const utf8 * buffer, size_t index)
{
size_t bufferSize = String::SizeOf(buffer);
bool goodSubstring = index <= bufferSize;
Guard::Assert(goodSubstring, "Substring past end of input string.");
// If assertion continues, return empty string to avoid crash
if (!goodSubstring)
{
return String::Duplicate("");
}
return String::Duplicate(buffer + index);
}
utf8 * Substring(const utf8 * buffer, size_t index, size_t size)
{
size_t bufferSize = String::SizeOf(buffer);
bool goodSubstring = index + size <= bufferSize;
Guard::Assert(goodSubstring, "Substring past end of input string.");
// If assertion continues, cap the substring to avoid crash
if (!goodSubstring)
{
if (index >= bufferSize)
{
size = 0;
}
else
{
size = bufferSize - index;
}
}
utf8 * result = Memory::Allocate<utf8>(size + 1);
std::copy_n(buffer + index, size, result);
result[size] = '\0';
return result;
}
std::vector<std::string> Split(const std::string &s, const std::string &delimiter)
{
if (delimiter.empty())

View File

@ -70,16 +70,6 @@ namespace String
*/
utf8 * DiscardDuplicate(utf8 * * ptr, const utf8 * replacement);
/**
* Creates a new string containing the characters between index and the end of the input string.
*/
utf8 * Substring(const utf8 * buffer, size_t index);
/**
* Creates a new string containing the characters between index and index + size of the input string.
*/
utf8 * Substring(const utf8 * buffer, size_t index, size_t size);
/**
* Splits the given string by a delimiter and returns the values as a new string array.
* @returns the number of values.