-
Notifications
You must be signed in to change notification settings - Fork 199
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
refactor: avoid copy all attributes to parsed style #1807
base: release
Are you sure you want to change the base?
Conversation
b356280
to
5d202cf
Compare
5d202cf
to
1e43590
Compare
如果这样改的话,估计一定程度上会导致程序流程不清晰,比如:
另外,现在对象实例上存储属性的字段应该有 config/attributes/parsedStyle 等等,得了解下相关的字段代表的含义,为什么要这么设计,避免引起其它副作用 |
@wang1212 对于上层框架来说,有 10% 的时间用在拷贝属性到上来说是一个不小的开销。 |
看起来还会影响用户侧,这个可能会导致用户产生困惑,看看能不能搞清楚为啥要区分 attributes 和 parsedStyle,是为了兼容 dom 标准还是为了啥,能不能直接从架构设计层面精简掉 |
开销确实比较大,其实问题在于 attributes 和 parsedStyle 是不是算是内部 object 对象的实现细节,能不能通过 getter 和 setter 把内部实现隐藏掉,用户侧和渲染层不需要感知某个子模块的实现细节 |
G/packages/g-lite/src/css/StyleValueRegistry.ts
中将 attribuets 中属性拷贝至 parsedStyle 会花费一定时间,并造成内存开销增加。这个 PR 对相关逻辑进行改造,只有真正解析转换的属性才会存放至 parsedStyle,其余地方需根据情况访问。尽管导致了维护成本增加,但一定程度上能够优化性能