Commit 64b35259 authored by HeinrichAD's avatar HeinrichAD
Browse files

Optimization

Load an attribute only once if possible.
parent 6398bf72
...@@ -39,7 +39,7 @@ namespace Svg ...@@ -39,7 +39,7 @@ namespace Svg
[SvgAttribute("fill", true)] [SvgAttribute("fill", true)]
public virtual SvgPaintServer Fill public virtual SvgPaintServer Fill
{ {
get { return (this.Attributes["fill"] == null) ? SvgColourServer.NotSet : (SvgPaintServer)this.Attributes["fill"]; } get { return ((SvgPaintServer)this.Attributes["fill"] ?? SvgColourServer.NotSet); }
set { this.Attributes["fill"] = value; } set { this.Attributes["fill"] = value; }
} }
...@@ -49,14 +49,14 @@ namespace Svg ...@@ -49,14 +49,14 @@ namespace Svg
[SvgAttribute("stroke", true)] [SvgAttribute("stroke", true)]
public virtual SvgPaintServer Stroke public virtual SvgPaintServer Stroke
{ {
get { return (this.Attributes["stroke"] == null) ? null : (SvgPaintServer)this.Attributes["stroke"]; } get { return (SvgPaintServer)this.Attributes["stroke"]; }
set { this.Attributes["stroke"] = value; } set { this.Attributes["stroke"] = value; }
} }
[SvgAttribute("fill-rule", true)] [SvgAttribute("fill-rule", true)]
public virtual SvgFillRule FillRule public virtual SvgFillRule FillRule
{ {
get { return (this.Attributes["fill-rule"] == null) ? SvgFillRule.NonZero : (SvgFillRule)this.Attributes["fill-rule"]; } get { return (SvgFillRule)(this.Attributes["fill-rule"] ?? SvgFillRule.NonZero); }
set { this.Attributes["fill-rule"] = value; } set { this.Attributes["fill-rule"] = value; }
} }
...@@ -66,7 +66,7 @@ namespace Svg ...@@ -66,7 +66,7 @@ namespace Svg
[SvgAttribute("fill-opacity", true)] [SvgAttribute("fill-opacity", true)]
public virtual float FillOpacity public virtual float FillOpacity
{ {
get { return (this.Attributes["fill-opacity"] == null) ? this.Opacity : (float)this.Attributes["fill-opacity"]; } get { return (float)(this.Attributes["fill-opacity"] ?? this.Opacity); }
set { this.Attributes["fill-opacity"] = FixOpacityValue(value); } set { this.Attributes["fill-opacity"] = FixOpacityValue(value); }
} }
...@@ -76,28 +76,28 @@ namespace Svg ...@@ -76,28 +76,28 @@ namespace Svg
[SvgAttribute("stroke-width", true)] [SvgAttribute("stroke-width", true)]
public virtual SvgUnit StrokeWidth public virtual SvgUnit StrokeWidth
{ {
get { return (this.Attributes["stroke-width"] == null) ? new SvgUnit(1.0f) : (SvgUnit)this.Attributes["stroke-width"]; } get { return (SvgUnit)(this.Attributes["stroke-width"] ?? new SvgUnit(1.0f)); }
set { this.Attributes["stroke-width"] = value; } set { this.Attributes["stroke-width"] = value; }
} }
[SvgAttribute("stroke-linecap", true)] [SvgAttribute("stroke-linecap", true)]
public virtual SvgStrokeLineCap StrokeLineCap public virtual SvgStrokeLineCap StrokeLineCap
{ {
get { return (this.Attributes["stroke-linecap"] == null) ? SvgStrokeLineCap.Butt : (SvgStrokeLineCap)this.Attributes["stroke-linecap"]; } get { return (SvgStrokeLineCap)(this.Attributes["stroke-linecap"] ?? SvgStrokeLineCap.Butt); }
set { this.Attributes["stroke-linecap"] = value; } set { this.Attributes["stroke-linecap"] = value; }
} }
[SvgAttribute("stroke-linejoin", true)] [SvgAttribute("stroke-linejoin", true)]
public virtual SvgStrokeLineJoin StrokeLineJoin public virtual SvgStrokeLineJoin StrokeLineJoin
{ {
get { return (this.Attributes["stroke-linejoin"] == null) ? SvgStrokeLineJoin.Miter : (SvgStrokeLineJoin)this.Attributes["stroke-linejoin"]; } get { return (SvgStrokeLineJoin)(this.Attributes["stroke-linejoin"] ?? SvgStrokeLineJoin.Miter); }
set { this.Attributes["stroke-linejoin"] = value; } set { this.Attributes["stroke-linejoin"] = value; }
} }
[SvgAttribute("stroke-miterlimit", true)] [SvgAttribute("stroke-miterlimit", true)]
public virtual float StrokeMiterLimit public virtual float StrokeMiterLimit
{ {
get { return (this.Attributes["stroke-miterlimit"] == null) ? 4f : (float)this.Attributes["stroke-miterlimit"]; } get { return (float)(this.Attributes["stroke-miterlimit"] ?? 4f); }
set { this.Attributes["stroke-miterlimit"] = value; } set { this.Attributes["stroke-miterlimit"] = value; }
} }
...@@ -111,7 +111,7 @@ namespace Svg ...@@ -111,7 +111,7 @@ namespace Svg
[SvgAttribute("stroke-dashoffset", true)] [SvgAttribute("stroke-dashoffset", true)]
public virtual SvgUnit StrokeDashOffset public virtual SvgUnit StrokeDashOffset
{ {
get { return (this.Attributes["stroke-dashoffset"] == null) ? SvgUnit.Empty : (SvgUnit)this.Attributes["stroke-dashoffset"]; } get { return (SvgUnit)(this.Attributes["stroke-dashoffset"] ?? SvgUnit.Empty); }
set { this.Attributes["stroke-dashoffset"] = value; } set { this.Attributes["stroke-dashoffset"] = value; }
} }
...@@ -121,7 +121,7 @@ namespace Svg ...@@ -121,7 +121,7 @@ namespace Svg
[SvgAttribute("stroke-opacity", true)] [SvgAttribute("stroke-opacity", true)]
public virtual float StrokeOpacity public virtual float StrokeOpacity
{ {
get { return (this.Attributes["stroke-opacity"] == null) ? this.Opacity : (float)this.Attributes["stroke-opacity"]; } get { return (float)(this.Attributes["stroke-opacity"] ?? this.Opacity); }
set { this.Attributes["stroke-opacity"] = FixOpacityValue(value); } set { this.Attributes["stroke-opacity"] = FixOpacityValue(value); }
} }
...@@ -143,7 +143,7 @@ namespace Svg ...@@ -143,7 +143,7 @@ namespace Svg
[SvgAttribute("opacity", true)] [SvgAttribute("opacity", true)]
public virtual float Opacity public virtual float Opacity
{ {
get { return (this.Attributes["opacity"] == null) ? 1.0f : (float)this.Attributes["opacity"]; } get { return (float)(this.Attributes["opacity"] ?? 1.0f); }
set { this.Attributes["opacity"] = FixOpacityValue(value); } set { this.Attributes["opacity"] = FixOpacityValue(value); }
} }
...@@ -173,7 +173,7 @@ namespace Svg ...@@ -173,7 +173,7 @@ namespace Svg
[SvgAttribute("font-size", true)] [SvgAttribute("font-size", true)]
public virtual SvgUnit FontSize public virtual SvgUnit FontSize
{ {
get { return (this.Attributes["font-size"] == null) ? SvgUnit.Empty : (SvgUnit)this.Attributes["font-size"]; } get { return (SvgUnit)(this.Attributes["font-size"] ?? SvgUnit.Empty); }
set { this.Attributes["font-size"] = value; this.IsPathDirty = true; } set { this.Attributes["font-size"] = value; this.IsPathDirty = true; }
} }
...@@ -183,7 +183,7 @@ namespace Svg ...@@ -183,7 +183,7 @@ namespace Svg
[SvgAttribute("font-style", true)] [SvgAttribute("font-style", true)]
public virtual SvgFontStyle FontStyle public virtual SvgFontStyle FontStyle
{ {
get { return (this.Attributes["font-style"] == null) ? SvgFontStyle.All : (SvgFontStyle)this.Attributes["font-style"]; } get { return (SvgFontStyle)(this.Attributes["font-style"] ?? SvgFontStyle.All); }
set { this.Attributes["font-style"] = value; this.IsPathDirty = true; } set { this.Attributes["font-style"] = value; this.IsPathDirty = true; }
} }
...@@ -193,7 +193,7 @@ namespace Svg ...@@ -193,7 +193,7 @@ namespace Svg
[SvgAttribute("font-variant", true)] [SvgAttribute("font-variant", true)]
public virtual SvgFontVariant FontVariant public virtual SvgFontVariant FontVariant
{ {
get { return (this.Attributes["font-variant"] == null) ? SvgFontVariant.Inherit : (SvgFontVariant)this.Attributes["font-variant"]; } get { return (SvgFontVariant)(this.Attributes["font-variant"] ?? SvgFontVariant.Inherit); }
set { this.Attributes["font-variant"] = value; this.IsPathDirty = true; } set { this.Attributes["font-variant"] = value; this.IsPathDirty = true; }
} }
...@@ -203,7 +203,7 @@ namespace Svg ...@@ -203,7 +203,7 @@ namespace Svg
[SvgAttribute("text-decoration", true)] [SvgAttribute("text-decoration", true)]
public virtual SvgTextDecoration TextDecoration public virtual SvgTextDecoration TextDecoration
{ {
get { return (this.Attributes["text-decoration"] == null) ? SvgTextDecoration.Inherit : (SvgTextDecoration)this.Attributes["text-decoration"]; } get { return (SvgTextDecoration)(this.Attributes["text-decoration"] ?? SvgTextDecoration.Inherit); }
set { this.Attributes["text-decoration"] = value; this.IsPathDirty = true; } set { this.Attributes["text-decoration"] = value; this.IsPathDirty = true; }
} }
...@@ -213,7 +213,7 @@ namespace Svg ...@@ -213,7 +213,7 @@ namespace Svg
[SvgAttribute("font-weight", true)] [SvgAttribute("font-weight", true)]
public virtual SvgFontWeight FontWeight public virtual SvgFontWeight FontWeight
{ {
get { return (this.Attributes["font-weight"] == null) ? SvgFontWeight.Inherit : (SvgFontWeight)this.Attributes["font-weight"]; } get { return (SvgFontWeight)(this.Attributes["font-weight"] ?? SvgFontWeight.Inherit); }
set { this.Attributes["font-weight"] = value; this.IsPathDirty = true; } set { this.Attributes["font-weight"] = value; this.IsPathDirty = true; }
} }
...@@ -233,7 +233,7 @@ namespace Svg ...@@ -233,7 +233,7 @@ namespace Svg
[SvgAttribute("font", true)] [SvgAttribute("font", true)]
public virtual string Font public virtual string Font
{ {
get { return (this.Attributes["font"] == null ? "" : this.Attributes["font"] as string); } get { return ((this.Attributes["font"] ?? string.Empty) as string); }
set set
{ {
var state = FontParseState.fontStyle; var state = FontParseState.fontStyle;
...@@ -308,8 +308,6 @@ namespace Svg ...@@ -308,8 +308,6 @@ namespace Svg
} }
} }
private const string DefaultFontFamily = "Times New Roman";
/// <summary> /// <summary>
/// Get the font information based on data stored with the text object or inherited from the parent. /// Get the font information based on data stored with the text object or inherited from the parent.
/// </summary> /// </summary>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment