-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Currently in the ToUpper/ToLower/Trim functions there is a small char allocation for an array each time these functions are called, which is not required. The following code could be replaced:
from:
public Sbt ToLower()
{
char[] tmp = new char[1];
int length = sb.Length;
for (int i = 0; i < length; ++i)
{
sb.CopyTo(i, tmp, 0, 1);
if (char.IsUpper(tmp[0]))
{
sb.Replace(tmp[0], char.ToLower(tmp[0]), i, 1);
}
}
return this;
}to:
public Sbt ToLower ()
{
int length = sb.Length;
for (int i = 0; i < length; ++i) {
char x = sb[i];
if (char.IsUpper (x)) {
sb[i] = char.ToLower (x);
}
}
return this;
}This can be true of all these functions, and its slightly faster than the previous cases.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels