Browse Source

Reduced allocations: Rotate Fluent API

Marcin Ziąbek 2 years ago
parent
commit
e6821d8f63
1 changed files with 4 additions and 5 deletions
  1. 4 5
      Source/QuestPDF/Fluent/RotateExtensions.cs

+ 4 - 5
Source/QuestPDF/Fluent/RotateExtensions.cs

@@ -6,11 +6,10 @@ namespace QuestPDF.Fluent
 {
 {
     public static class RotateExtensions
     public static class RotateExtensions
     {
     {
-        private static IContainer SimpleRotate(this IContainer element, Action<SimpleRotate> handler)
+        private static IContainer SimpleRotate(this IContainer element, int turnDirection)
         {
         {
             var scale = element as SimpleRotate ?? new SimpleRotate();
             var scale = element as SimpleRotate ?? new SimpleRotate();
-            handler(scale);
-            
+            scale.TurnCount += turnDirection;
             return element.Element(scale);
             return element.Element(scale);
         }
         }
         
         
@@ -23,7 +22,7 @@ namespace QuestPDF.Fluent
         /// </remarks>
         /// </remarks>
         public static IContainer RotateLeft(this IContainer element)
         public static IContainer RotateLeft(this IContainer element)
         {
         {
-            return element.SimpleRotate(x => x.TurnCount--);
+            return element.SimpleRotate(-1);
         }
         }
         
         
         /// <summary>
         /// <summary>
@@ -35,7 +34,7 @@ namespace QuestPDF.Fluent
         /// </remarks>
         /// </remarks>
         public static IContainer RotateRight(this IContainer element)
         public static IContainer RotateRight(this IContainer element)
         {
         {
-            return element.SimpleRotate(x => x.TurnCount++);
+            return element.SimpleRotate(1);
         }
         }
         
         
         /// <summary>
         /// <summary>