Bladeren bron

optimization: prevent allocs in ScaleGrid checkUpdate

trethaller 2 jaren geleden
bovenliggende
commit
7ade01961a
2 gewijzigde bestanden met toevoegingen van 5 en 6 verwijderingen
  1. 1 1
      h2d/Object.hx
  2. 4 5
      h2d/col/Matrix.hx

+ 1 - 1
h2d/Object.hx

@@ -180,7 +180,7 @@ class Object #if (domkit && !domkit_heaps) implements domkit.Model<h2d.Object> #
 	/**
 		Returns the updated absolute position matrix. See `Object.getMatrix` for current matrix values.
 	**/
-	public function getAbsPos() {
+	inline public function getAbsPos() {
 		syncPos();
 		var m = new h2d.col.Matrix();
 		m.a = matA;

+ 4 - 5
h2d/col/Matrix.hx

@@ -24,7 +24,7 @@ class Matrix {
 	/**
 		Create a new identity Matrix.
 	**/
-	public function new() {
+	inline public function new() {
 		identity();
 	}
 
@@ -189,7 +189,7 @@ class Matrix {
 	}
 
 	/**
-		Concatenates Matrix `a` and `b` and stores the result in this Matrix. 
+		Concatenates Matrix `a` and `b` and stores the result in this Matrix.
 		Matrix can be the target of of it's own `multiply`.
 		Keep in mind that order of matrixes matter in concatenation.
 	**/
@@ -208,9 +208,8 @@ class Matrix {
 		Returns a Point with a total scaling applied by the Matrix.
 		@param p Optional Point instance. If provided, sets values of given Point and returns it. Otherwise returns new Point instance.
 	**/
-	public inline function getScale(?p: h2d.col.Point) {
-		if(p == null)
-			p = new h2d.col.Point();
+	public inline function getScale() {
+		var p = new h2d.col.Point();
 		p.x = Math.sqrt(a * a + b * b);
 		p.y = Math.sqrt(c * c + d * d);
 		if( getDeterminant() < 0 ) {