Commit 07c5f69
improve: fast-path allocation checks in niceCamelName, capitalizeFirstLetter, Pluralizer
- niceCamelName: if nicePascalName result already starts with a lower-case
letter (empty result is also handled), return it directly with zero
allocation. Otherwise use StringBuilder.Append(string, startIndex, count)
to avoid creating an intermediate Substring for the tail.
- capitalizeFirstLetter: if the first char is already upper-case, return
the input string directly. The length-1 path is unchanged. The general
case now also uses StringBuilder to avoid two intermediate strings.
- Pluralizer: replace s.Substring(0, 1).ToUpperInvariant() (which allocates
a 1-char string then a new string for the result) with the simpler
(Char.ToUpperInvariant s.[0]).ToString() pattern consistent with the
rest of NameUtils.
Bumps version to 8.1.8.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent dac71d4 commit 07c5f69
3 files changed
Lines changed: 23 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 70 | + | |
| 71 | + | |
73 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
74 | 79 | | |
75 | 80 | | |
76 | 81 | | |
| |||
115 | 120 | | |
116 | 121 | | |
117 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
118 | 126 | | |
119 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
120 | 134 | | |
121 | 135 | | |
122 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| |||
0 commit comments