Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced concat with push for performance #513

Merged
merged 1 commit into from
May 21, 2022

Conversation

Balearica
Copy link
Contributor

@Balearica Balearica commented May 12, 2022

Description

Replaces instances of d = d.concat(...) with push within encoding functions for improved performance per #512. Should not impact results.

Motivation and Context

This version is faster, particularly on Firefox. As a test, I ran window.font.download() in the console of the https://opentype.js.org/ site. In Firefox the change reduced runtime from 1,341ms to 190ms. Chrome experienced a more modest improvement from 203ms to 166ms. The ability to quickly generate custom font files is important for my project Scribe OCR, and I'm sure others as well.

How Has This Been Tested?

The unit tests pass and I am using this version in my live site. Additionally, the change is conceptually simple and narrow in scope.

Types of changes

  • [x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I did npm run test and all tests passed green (including code styling checks).
  • I have added tests to cover my changes.
  • My change requires a change to the documentation.
  • I have updated the README accordingly.
  • I have read the CONTRIBUTING document.

@yne yne merged commit 423b611 into opentypejs:master May 21, 2022
@yne
Copy link
Contributor

yne commented May 21, 2022

It seems related to the fact that
.concat() create an intermediate array
.push() mutate the existing array

Very nice improvement 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants