Skip to content

Commit afbe170

Browse files
committed
Change: Some Tweaks
1 parent be58318 commit afbe170

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/CodeOfChaos.Extensions/StringCaseExtensions.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static partial class StringCaseExtensions {
1818
// Convert to PascalCase
1919
[SuppressMessage("ReSharper", "ForCanBeConvertedToForeach")]
2020
public static string ToPascalCase(this string input) {
21-
if (string.IsNullOrWhiteSpace(input)) return input;
21+
if (input.IsNullOrWhiteSpace()) return input;
2222

2323
ReadOnlySpan<string> words = NonAlphanumericRegex.Split(input);
2424

@@ -38,23 +38,21 @@ public static string ToPascalCase(this string input) {
3838
result[position++] = wordSpan[i].ToLower();
3939
}
4040
}
41-
4241
return new string(result[..position]);
4342
}
44-
45-
43+
4644
// Convert to camelCase
4745
[SuppressMessage("ReSharper", "ForCanBeConvertedToForeach")]
4846
public static string ToCamelCase(this string input) {
49-
if (string.IsNullOrWhiteSpace(input)) return input;
47+
if (input.IsNullOrWhiteSpace()) return input;
5048

5149
ReadOnlySpan<string> words = NonAlphanumericRegex.Split(input);
5250

5351
Span<char> result = stackalloc char[input.Length];
5452
int position = 0;
5553

5654
for (int i = 0; i < words.Length; i++) {
57-
if (string.IsNullOrEmpty(words[i])) continue;
55+
if (words[i].IsNullOrEmpty()) continue;
5856

5957
ReadOnlySpan<char> wordSpan = words[i].AsSpan();
6058

@@ -67,14 +65,13 @@ public static string ToCamelCase(this string input) {
6765
result[position++] = wordSpan[j];
6866
}
6967
}
70-
7168
return new string(result[..position]);
7269
}
7370

7471
// Convert to kebab-case
7572
[SuppressMessage("ReSharper", "ForCanBeConvertedToForeach")]
7673
public static string ToKebabCase(this string input) {
77-
if (string.IsNullOrWhiteSpace(input)) return input;
74+
if (input.IsNullOrWhiteSpace()) return input;
7875

7976
ReadOnlySpan<string> words = NonAlphanumericRegex.Split(input);
8077

@@ -101,7 +98,7 @@ public static string ToKebabCase(this string input) {
10198
// Convert to snake_case
10299
[SuppressMessage("ReSharper", "ForCanBeConvertedToForeach")]
103100
public static string ToSnakeCase(this string input) {
104-
if (string.IsNullOrWhiteSpace(input)) return input;
101+
if (input.IsNullOrWhiteSpace()) return input;
105102

106103
ReadOnlySpan<string> words = NonAlphanumericRegex.Split(input);
107104

@@ -129,7 +126,7 @@ public static string ToSnakeCase(this string input) {
129126
// Convert to period.separated.case
130127
[SuppressMessage("ReSharper", "ForCanBeConvertedToForeach")]
131128
public static string ToPeriodSeparatedCase(this string input) {
132-
if (string.IsNullOrWhiteSpace(input)) return input;
129+
if (input.IsNullOrWhiteSpace()) return input;
133130

134131
ReadOnlySpan<string> words = NonAlphanumericRegex.Split(input);
135132

0 commit comments

Comments
 (0)