-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance and reduce memory use and reduce array allocation…
…s by reusing char[] (#9166) * Reduce array allocations by reusing char[] * don't hide .Equals() * Reduce memory use by reducing array allocations * Revert "Reduce memory use by reducing array allocations" This reverts commit faf6b60. * reuse char[] for string.split() to avoid params [] allocation
- Loading branch information
Showing
97 changed files
with
310 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Umbraco.Core | ||
{ | ||
public static partial class Constants | ||
{ | ||
/// <summary> | ||
/// Char Arrays to avoid allocations | ||
/// </summary> | ||
public static class CharArrays | ||
{ | ||
/// <summary> | ||
/// Char array containing only / | ||
/// </summary> | ||
public static readonly char[] ForwardSlash = new char[] { '/' }; | ||
|
||
/// <summary> | ||
/// Char array containing only \ | ||
/// </summary> | ||
public static readonly char[] Backslash = new char[] { '\\' }; | ||
|
||
/// <summary> | ||
/// Char array containing only ' | ||
/// </summary> | ||
public static readonly char[] SingleQuote = new char[] { '\'' }; | ||
|
||
/// <summary> | ||
/// Char array containing only " | ||
/// </summary> | ||
public static readonly char[] DoubleQuote = new char[] { '\"' }; | ||
|
||
|
||
/// <summary> | ||
/// Char array containing ' " | ||
/// </summary> | ||
public static readonly char[] DoubleQuoteSingleQuote = new char[] { '\"', '\'' }; | ||
|
||
/// <summary> | ||
/// Char array containing only _ | ||
/// </summary> | ||
public static readonly char[] Underscore = new char[] { '_' }; | ||
|
||
/// <summary> | ||
/// Char array containing \n \r | ||
/// </summary> | ||
public static readonly char[] LineFeedCarriageReturn = new char[] { '\n', '\r' }; | ||
|
||
|
||
/// <summary> | ||
/// Char array containing \n | ||
/// </summary> | ||
public static readonly char[] LineFeed = new char[] { '\n' }; | ||
|
||
/// <summary> | ||
/// Char array containing only , | ||
/// </summary> | ||
public static readonly char[] Comma = new char[] { ',' }; | ||
|
||
/// <summary> | ||
/// Char array containing only & | ||
/// </summary> | ||
public static readonly char[] Ampersand = new char[] { '&' }; | ||
|
||
/// <summary> | ||
/// Char array containing only \0 | ||
/// </summary> | ||
public static readonly char[] NullTerminator = new char[] { '\0' }; | ||
|
||
/// <summary> | ||
/// Char array containing only . | ||
/// </summary> | ||
public static readonly char[] Period = new char[] { '.' }; | ||
|
||
/// <summary> | ||
/// Char array containing only ~ | ||
/// </summary> | ||
public static readonly char[] Tilde = new char[] { '~' }; | ||
/// <summary> | ||
/// Char array containing ~ / | ||
/// </summary> | ||
public static readonly char[] TildeForwardSlash = new char[] { '~', '/' }; | ||
|
||
/// <summary> | ||
/// Char array containing only ? | ||
/// </summary> | ||
public static readonly char[] QuestionMark = new char[] { '?' }; | ||
|
||
/// <summary> | ||
/// Char array containing ? & | ||
/// </summary> | ||
public static readonly char[] QuestionMarkAmpersand = new char[] { '?', '&' }; | ||
|
||
/// <summary> | ||
/// Char array containing XML 1.1 whitespace chars | ||
/// </summary> | ||
public static readonly char[] XmlWhitespaceChars = new char[] { ' ', '\t', '\r', '\n' }; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
/// <summary> | ||
/// Char array containing only the Space char | ||
/// </summary> | ||
public static readonly char[] Space = new char[] { ' ' }; | ||
|
||
/// <summary> | ||
/// Char array containing only ; | ||
/// </summary> | ||
public static readonly char[] Semicolon = new char[] { ';' }; | ||
|
||
/// <summary> | ||
/// Char array containing a comma and a space | ||
/// </summary> | ||
public static readonly char[] CommaSpace = new char[] { ',', ' ' }; | ||
|
||
/// <summary> | ||
/// Char array containing _ - | ||
/// </summary> | ||
public static readonly char[] UnderscoreDash = new char[] { '_', '-' }; | ||
|
||
/// <summary> | ||
/// Char array containing = | ||
/// </summary> | ||
public static readonly char[] EqualsChar = new char[] { '=' }; | ||
This comment has been minimized.
Sorry, something went wrong.
bjarnef
Contributor
|
||
|
||
/// <summary> | ||
/// Char array containing > | ||
/// </summary> | ||
public static readonly char[] GreaterThan = new char[] { '>' }; | ||
|
||
/// <summary> | ||
/// Char array containing | | ||
/// </summary> | ||
public static readonly char[] VerticalTab = new char[] { '|' }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Maybe just naming it
XmlWhitespaces
?