Przeglądaj źródła

Re-use static variable instead of method call in TextStyle

Maarten Balliauw 3 lat temu
rodzic
commit
c5fbf7263c
1 zmienionych plików z 8 dodań i 2 usunięć
  1. 8 2
      QuestPDF/Infrastructure/TextStyle.cs

+ 8 - 2
QuestPDF/Infrastructure/TextStyle.cs

@@ -22,7 +22,10 @@ namespace QuestPDF.Infrastructure
         internal object PaintKey { get; private set; }
         internal object FontMetricsKey { get; private set; }
         
-        internal static TextStyle LibraryDefault => new TextStyle
+        // REVIEW: Should this be a method call that news up a TextStyle,
+        // or can it be a static variable?
+        // (style mutations seem to create a clone anyway)
+        internal static readonly TextStyle LibraryDefault = new TextStyle
         {
             Color = Colors.Black,
             BackgroundColor = Colors.Transparent,
@@ -37,7 +40,10 @@ namespace QuestPDF.Infrastructure
             WrapAnywhere = false
         };
 
-        public static TextStyle Default => new TextStyle();
+        // REVIEW: Should this be a method call that news up a TextStyle,
+        // or can it be a static variable?
+        // (style mutations seem to create a clone anyway)
+        public static readonly TextStyle Default = new TextStyle();
         
         internal void ApplyGlobalStyle(TextStyle globalStyle)
         {