Open Karbashevskyi opened 3 weeks ago
On Sun, Aug 18, 2024 at 11:09 PM Karba @.***> wrote:
Remember the words of the great Demi Murich that using this kind of destructuring generates two A4 sheets of code bytes. Suggestion:
const {0: name, 1: ver = '*'} = unitName.split('.');
— Reply to this email directly, view it on GitHub https://github.com/metarhia/impress/issues/1973, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBTQMKVI6TDXHVGMEGSGCLZSD5QVAVCNFSM6AAAAABMWUOYU2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TEMJSGU2TONI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hello!
this certain place of code is not hot, if we will optimize, we will do it in the following way:
const { first: name, rest: ver = '*' } = split(unitName, '.');
Where split is:
const split = (s, separator) => { const i = s.indexOf(separator); const result = { first: s, rest: '' }; if (i >= 0) { result.first = s.slice(0, i); result.rest = s.slice(i + separator.length); } return result; };
Best regards, ~Timur Shemsedinov
https://github.com/metarhia/impress/blob/d35b3256e957ec27fb9aae26e15a3e23f051adf9/lib/application.js#L233
Remember the words of the great Demi Murich that using this kind of destructuring generates two A4 sheets of code bytes. Suggestion: