Fix for #91 - Turn some commonly allocated types into structs
These types are allocated for every state transition in the parser (State) or every character that's read (character reference) and are fairly compact. Turning them into structs will remove a significant number of unnecessary allocations in the parser. For our razor code generation benchmark, making these changes yields about 500-750ms of speedup (out of 40000ms) or about 1%.
This commit is contained in:
parent
102e2e5739
commit
2d9b3dd4fb
|
|
@ -114,16 +114,19 @@ namespace Microsoft.AspNet.Razor.Text
|
|||
return null;
|
||||
}
|
||||
|
||||
internal class CharacterReference
|
||||
internal struct CharacterReference
|
||||
{
|
||||
private readonly char _character;
|
||||
private readonly SourceLocation _location;
|
||||
|
||||
public CharacterReference(char character, SourceLocation location)
|
||||
{
|
||||
Character = character;
|
||||
Location = location;
|
||||
_character = character;
|
||||
_location = location;
|
||||
}
|
||||
|
||||
public char Character { get; private set; }
|
||||
public SourceLocation Location { get; private set; }
|
||||
public char Character { get { return _character; } }
|
||||
public SourceLocation Location { get { return _location; } }
|
||||
}
|
||||
|
||||
private class TextLine
|
||||
|
|
|
|||
Loading…
Reference in New Issue