Skip to content

Commit 2e09168

Browse files
committed
Don't return new TransformationMatrix when multiplying with identity matrix reducing memory footprint
1 parent 9bf93b3 commit 2e09168

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/Document/ContentStream/PositionedText/TransformationMatrix.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ public function __construct(
1414

1515
/** Please note that a concatenated transformation matrix of A B !== B A */
1616
public function multiplyWith(self $other): self {
17+
if ($other->scaleX === 1.0
18+
&& $other->scaleY === 1.0
19+
&& $other->shearX === 0.0
20+
&& $other->shearY === 0.0
21+
&& $other->offsetX === 0.0
22+
&& $other->offsetY === 0.0
23+
) {
24+
return $this; // When multiplying with the identity matrix, the current matrix is unchanged
25+
}
26+
1727
return new self(
1828
$this->scaleX * $other->scaleX + $this->shearX * $other->shearY,
1929
$this->scaleX * $other->shearX + $this->shearX * $other->scaleY,

0 commit comments

Comments
 (0)