Fix StringViewAnsi substring to not allocate

This commit is contained in:
2026-06-01 16:19:28 +02:00
parent caeecf2aea
commit 96835b856d
3 changed files with 12 additions and 12 deletions
+4 -4
View File
@@ -101,8 +101,8 @@ FORCE_INLINE bool GuidParse(const StringViewType& text, Guid& value)
// FormatType::D
case 36:
{
StringType b = StringType(text.Substring(9, 4)) + text.Substring(14, 4);
StringType c = StringType(text.Substring(19, 4)) + text.Substring(24, 4);
StringType b = StringType(text.Substring(9, 4)) + StringType(text.Substring(14, 4));
StringType c = StringType(text.Substring(19, 4)) + StringType(text.Substring(24, 4));
return
StringUtils::ParseHex(*text + 0, 8, &value.A) ||
StringUtils::ParseHex(*b, &value.B) ||
@@ -113,8 +113,8 @@ FORCE_INLINE bool GuidParse(const StringViewType& text, Guid& value)
// FormatType::P
case 38:
{
StringType b = StringType(text.Substring(10, 4)) + text.Substring(15, 4);
StringType c = StringType(text.Substring(20, 4)) + text.Substring(25, 4);
StringType b = StringType(text.Substring(10, 4)) + StringType(text.Substring(15, 4));
StringType c = StringType(text.Substring(20, 4)) + StringType(text.Substring(25, 4));
return
text[0] != text[text.Length() - 1] ||
StringUtils::ParseHex(*text + 1, 8, &value.A) ||
+4 -4
View File
@@ -87,16 +87,16 @@ bool StringAnsiView::operator!=(const StringAnsi& other) const
return this->Compare(StringAnsiView(other)) != 0;
}
StringAnsi StringAnsiView::Substring(int32 startIndex) const
StringAnsiView StringAnsiView::Substring(int32 startIndex) const
{
ASSERT(startIndex >= 0 && startIndex < Length());
return StringAnsi(Get() + startIndex, Length() - startIndex);
return StringAnsiView(Get() + startIndex, Length() - startIndex);
}
StringAnsi StringAnsiView::Substring(int32 startIndex, int32 count) const
StringAnsiView StringAnsiView::Substring(int32 startIndex, int32 count) const
{
ASSERT(startIndex >= 0 && startIndex + count <= Length() && count >= 0);
return StringAnsi(Get() + startIndex, count);
return StringAnsiView(Get() + startIndex, count);
}
String StringAnsiView::ToString() const
+4 -4
View File
@@ -368,7 +368,7 @@ public:
StringView Right(int32 count) const;
/// <summary>
/// Retrieves substring created from characters starting from startIndex to the String end.
/// Retrieves substring created from characters starting from startIndex to the end.
/// </summary>
/// <param name="startIndex">The index of the first character to subtract.</param>
/// <returns>The substring created from String data.</returns>
@@ -550,11 +550,11 @@ public:
}
/// <summary>
/// Retrieves substring created from characters starting from startIndex to the String end.
/// Retrieves substring created from characters starting from startIndex to the end.
/// </summary>
/// <param name="startIndex">The index of the first character to subtract.</param>
/// <returns>The substring created from String data.</returns>
StringAnsi Substring(int32 startIndex) const;
StringAnsiView Substring(int32 startIndex) const;
/// <summary>
/// Retrieves substring created from characters starting from start index.
@@ -562,7 +562,7 @@ public:
/// <param name="startIndex">The index of the first character to subtract.</param>
/// <param name="count">The amount of characters to retrieve.</param>
/// <returns>The substring created from String data.</returns>
StringAnsi Substring(int32 startIndex, int32 count) const;
StringAnsiView Substring(int32 startIndex, int32 count) const;
public:
String ToString() const;