opentype.js
opentype.js copied to clipboard
add local eslint rule rule for banning concat and new performance test
Description
This adds a test for #683 as well as a new local eslint rule for banning concat(). In favour of push(...).
It also refactors all instances of concat() throughout the code base, so we should wait for several other outstanding PRs before merging this, in order to avoid a mass of conflicts. This PR is also blocked by #683 because it depends on it.
Motivation and Context
#513 and #683 show a clear performance improvement especially for larger/more complex fonts.
How Has This Been Tested?
Made sure the tests are all still passing.
Types of changes
- [ ] 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)
- [x] performance improvement
Checklist:
- [X] I did
npm run testand all tests passed green (including code styling checks). - [X] I have added tests to cover my changes.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the README accordingly.
- [X] I have read the CONTRIBUTING document.
The spread operator is quite slow as well. Used with a single push() call, it's still considerably slower than using multiple for() loops. See https://jsperf.app/cabimi
TODO: use this optimization in the refactored code as well