Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,21 @@ public override string ConvertName(string name)
return name;
}

#if BUILDING_INBOX_LIBRARY
return string.Create(name.Length, name, (chars, name) =>
{
name.AsSpan().CopyTo(chars);
FixCasing(chars);
});
#else
char[] chars = name.ToCharArray();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given property/key names are almost always small, is it worth it to copy the contents into a stackalloc span instead of always calling ToCharArray for say < 256?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? Feel free to look at that separately; I'm going to skip it for this PR. I'm also not sure how much time we want to invest in the OOBs.

FixCasing(chars);
return new string(chars);
#endif
}

private static void FixCasing(Span<char> chars)
{
for (int i = 0; i < chars.Length; i++)
{
if (i == 1 && !char.IsUpper(chars[i]))
Expand All @@ -38,8 +51,6 @@ public override string ConvertName(string name)

chars[i] = char.ToLowerInvariant(chars[i]);
}

return new string(chars);
}
}
}