Browse Source

Cache Selector.ToString()

Was actually adding up to a noticeable amount of time in large layouts.
pull/58/head
Steven Kirk 11 years ago
parent
commit
64a2edac01
  1. 17
      Perspex.Styling/Selector.cs

17
Perspex.Styling/Selector.cs

@ -17,6 +17,8 @@ namespace Perspex.Styling
private bool stopTraversal; private bool stopTraversal;
private string description;
public Selector() public Selector()
{ {
this.evaluate = _ => new SelectorMatch(true); this.evaluate = _ => new SelectorMatch(true);
@ -94,14 +96,19 @@ namespace Perspex.Styling
public override string ToString() public override string ToString()
{ {
string result = string.Empty; if (this.description == null)
if (this.Previous != null)
{ {
result = this.Previous.ToString(); string result = string.Empty;
if (this.Previous != null)
{
result = this.Previous.ToString();
}
this.description = result + this.SelectorString;
} }
return result + this.SelectorString; return this.description;
} }
} }
} }

Loading…
Cancel
Save