webpack / webpack-sources

Source code handling classes for webpack
MIT License
261 stars 71 forks source link

reducing memory allocation in ConcatSource and ReplaceSource #31

Closed MagicDuck closed 6 years ago

MagicDuck commented 6 years ago

using (+=) operator instead of array join/reduce to reduce memory allocation.

This causes nodejs to treat the strings internally as "concatenated strings" and reuse the pieces instead of allocating new memory. see: https://github.com/webpack/webpack-sources/issues/30

For the ConcatSource::size() change, we are simply removing the need to allocate an array to compute the size.

jsf-clabot commented 6 years ago

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Stephan Badragan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.

codecov[bot] commented 6 years ago

Codecov Report

Merging #31 into master will increase coverage by 0.41%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #31      +/-   ##
==========================================
+ Coverage   70.84%   71.25%   +0.41%     
==========================================
  Files          11       11              
  Lines         415      421       +6     
  Branches       64       64              
==========================================
+ Hits          294      300       +6     
  Misses        121      121
Impacted Files Coverage Δ
lib/ConcatSource.js 100% <100%> (ø) :arrow_up:
lib/ReplaceSource.js 92.85% <100%> (+0.11%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e1880a0...a28dd05. Read the comment docs.

sokra commented 6 years ago

Thanks