mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 08:38:06 +02:00
Optimize TextLayerRenderTask._layoutText
to avoid intermediate string creation
This method creates quite a few intermediate strings on each call and it's called often, even for smaller documents like the Tracemonkey document. Scrolling from top to bottom in that document resulted in 12936 strings being created in this method. With this commit applied, this is reduced to 3610 strings.
This commit is contained in:
parent
7c080584b6
commit
95f9075565
1 changed files with 3 additions and 3 deletions
|
@ -540,12 +540,12 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
|||
let transform = '';
|
||||
if (textDivProperties.canvasWidth !== 0 && width > 0) {
|
||||
textDivProperties.scale = textDivProperties.canvasWidth / width;
|
||||
transform = 'scaleX(' + textDivProperties.scale + ')';
|
||||
transform = `scaleX(${textDivProperties.scale})`;
|
||||
}
|
||||
if (textDivProperties.angle !== 0) {
|
||||
transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
|
||||
transform = `rotate(${textDivProperties.angle}deg) ${transform}`;
|
||||
}
|
||||
if (transform !== '') {
|
||||
if (transform.length > 0) {
|
||||
textDivProperties.originalTransform = transform;
|
||||
textDiv.style.transform = transform;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue