-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename 'MinimalUtility.String' to 'MinimalUtility.BackPort'
- Loading branch information
1 parent
6e4e107
commit ed7d9b8
Showing
28 changed files
with
100 additions
and
75 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ntime/String/MinimalUtility.String.asmdef → ...e/BackPort/MinimalUtility.BackPort.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
68 changes: 0 additions & 68 deletions
68
Packages/MinimalUtility/Runtime/String/StringUtils.Join.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Buffers; | ||
using System.Collections.Generic; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace MinimalUtility | ||
{ | ||
/// <summary> | ||
/// 文字列を扱うための静的メソッド群を提供します. | ||
/// </summary> | ||
public static partial class StringUtils | ||
{ | ||
/// <summary> | ||
/// 内部で<see cref="DefaultInterpolatedStringHandler"/>を使用した<see cref="string.Join(string,IEnumerable{string})"/>. | ||
/// </summary> | ||
/// <param name="separator">区切り文字列.</param> | ||
/// <param name="values">連結する文字列のコレクション.</param> | ||
/// <returns>連結された文字列.</returns> | ||
/// <exception cref="ArgumentNullException"><paramref name="values"/>がnullの場合にスローされます.</exception> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static string Join(in string? separator, IEnumerable<string?> values) => Join(separator.AsSpan(), values); | ||
|
||
/// <summary> | ||
/// 内部で<see cref="DefaultInterpolatedStringHandler"/>を使用した<see cref="string.Join{T}(char,IEnumerable{T})"/>. | ||
/// </summary> | ||
/// <param name="separator">区切り文字.</param> | ||
/// <param name="values">連結する文字列のコレクション.</param> | ||
/// <returns>連結された文字列.</returns> | ||
/// <exception cref="ArgumentNullException"><paramref name="values"/>がnullの場合にスローされます.</exception> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static string Join(in char separator, IEnumerable<string?> values) | ||
{ | ||
char[] separatorArray = ArrayPool<char>.Shared.Rent(1); | ||
separatorArray[0] = separator; | ||
string result = Join(new ReadOnlySpan<char>(separatorArray), values); | ||
ArrayPool<char>.Shared.Return(separatorArray); | ||
return result; | ||
} | ||
|
||
/// <summary> | ||
/// 内部で<see cref="DefaultInterpolatedStringHandler"/>を使用したstring.Join. | ||
/// </summary> | ||
/// <param name="separator">区切り文字列.</param> | ||
/// <param name="values">連結する文字列のコレクション.</param> | ||
/// <returns>連結された文字列.</returns> | ||
/// <exception cref="ArgumentNullException"><paramref name="values"/>がnullの場合にスローされます.</exception> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static string Join(in ReadOnlySpan<char> separator, IEnumerable<string?> values) | ||
{ | ||
if (values == null) | ||
{ | ||
throw new ArgumentNullException(nameof(values)); | ||
} | ||
|
||
using IEnumerator<string?> en = values.GetEnumerator(); | ||
if (!en.MoveNext()) | ||
{ | ||
return ""; | ||
} | ||
|
||
string? firstValue = en.Current; | ||
|
||
if (!en.MoveNext()) | ||
{ | ||
return firstValue ?? ""; | ||
} | ||
|
||
DefaultInterpolatedStringHandler result = new (); | ||
|
||
if (firstValue != null) | ||
{ | ||
result.AppendLiteral(firstValue); | ||
} | ||
|
||
do | ||
{ | ||
result.AppendFormatted(separator); | ||
if (en.Current != null) | ||
{ | ||
result.AppendLiteral(en.Current); | ||
} | ||
} | ||
while (en.MoveNext()); | ||
|
||
return result.ToString(); | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters