(#42) Short circuit char.Repeat count 0 and 1

This commit is contained in:
Oliver Booth 2021-07-20 01:02:02 +01:00
parent 132573e262
commit 25a40521c8
No known key found for this signature in database
GPG Key ID: A4AC17007530E9B4
1 changed files with 11 additions and 1 deletions

View File

@ -21,7 +21,17 @@ namespace X10D
{
throw new ArgumentOutOfRangeException(nameof(count), ExceptionMessages.CountMustBeGreaterThanOrEqualTo0);
}
if (count == 0)
{
return string.Empty;
}
if (count == 1)
{
return value.ToString();
}
return new string(value, count);
}
}