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

遍历继承链构建默认attrs的时机讨论 #26

Open
lianqin7 opened this issue Jul 8, 2013 · 0 comments
Open

遍历继承链构建默认attrs的时机讨论 #26

lianqin7 opened this issue Jul 8, 2013 · 0 comments
Labels

Comments

@lianqin7
Copy link
Member

lianqin7 commented Jul 8, 2013

目前 base及其子类 遍历继承链并构建默认atts的时机是在 类实例化 时,见代码:https://github.com/aralejs/base/blob/master/src/attribute.js#L19

个人觉得不合理且对性能有大影响:

  1. 设置在 prototype 上的 attrs 从规范上来说是不允许修改的,所以每次实例化的时候重新构建没有意义
  2. 每次实例化的时候都从最底层一直构建到最顶层,而且同个类每次实例都要构建一次,是性能上的大浪费

所以希望能将 遍历继承链并构建默认atts 的时机改为 类构建 时,可以提升很大一部分性能

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

No branches or pull requests

1 participant