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

reactivity/baseHandler.ts createGetter中的优化点 #104

Open
sdutwsl opened this issue Jun 9, 2023 · 1 comment
Open

reactivity/baseHandler.ts createGetter中的优化点 #104

sdutwsl opened this issue Jun 9, 2023 · 1 comment

Comments

@sdutwsl
Copy link

sdutwsl commented Jun 9, 2023

const isExistInReactiveMap = () =>
      key === ReactiveFlags.RAW && receiver === reactiveMap.get(target);

const isExistInReadonlyMap = () =>
      key === ReactiveFlags.RAW && receiver === readonlyMap.get(target);

const isExistInShallowReadonlyMap = () =>
      key === ReactiveFlags.RAW && receiver === shallowReadonlyMap.get(target);

这三个常量写为函数对象似乎并没有什么实质性作用,vue3现在的代码已经实现为:

      (key === ReactiveFlags.RAW &&
      receiver ===
        (isReadonly
          ? shallow
            ? shallowReadonlyMap
            : readonlyMap
          : shallow
          ? shallowReactiveMap
          : reactiveMap
        ).get(target))

也许可以优化下。

@viacooter
Copy link

viacooter commented Jun 9, 2023 via email

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

No branches or pull requests

2 participants