Skip to content

disable deconstruction and assignment #2398

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

Closed
wants to merge 7 commits into from
Closed

Conversation

deyihu
Copy link
Collaborator

@deyihu deyihu commented Aug 13, 2024

fix #2397

why?

mtk的的编译是 es5,使用高级语法回导致tsc里进行tslib polyfill,导致性能下降

下面是tslib polyfill的 解构和赋值的polyfill 函数

 function __read(o, n) {
      var m = typeof Symbol === "function" && o[Symbol.iterator];
      if (!m) return o;
      var i = m.call(o), r, ar = [], e;
      try {
          while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
      }
      catch (error) { e = { error: error }; }
      finally {
          try {
              if (r && !r.done && (m = i["return"])) m.call(i);
          }
          finally { if (e) throw e.error; }
      }
      return ar;
  }

@deyihu deyihu changed the title disable array deconstruction and assignment disable deconstruction and assignment Aug 13, 2024
@fuzhenn
Copy link
Member

fuzhenn commented Sep 5, 2024

感谢在这个pr里所做的工作,该pr通过移除有性能问题的es6语法来改进了性能,但也有以下几个缺点:

  • 代码无法利用新的语法特性
  • 后续开发的心智负担,需要时刻注意避免使用这些新语法

我感觉可以通过定制babel的编译参数,避免编译这些会产生性能问题的语法,达到目的的同时也能避免上述缺点。

具体请参考 #2415

@deyihu deyihu closed this Sep 5, 2024
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.

Minimize the use of array deconstruction and assignment as much as possible
2 participants