Skip to content

Commit

Permalink
[BUGFIX release] Simplify mixin application
Browse files Browse the repository at this point in the history
Simplifies mixin application in a number of ways:

- Ensures that we only access `meta` once for a given object when
  applying mixins
- Ensures that we only `peekDescriptors` once for a given descriptor
- Minimizes the number of if/else branches and defaulting in general
- Breaks apart `defineProperty` so that we can do less work per
  definition when mixing in mixins, since we know more about what
  possible operations will occur.
- Removes extra brand checks from `defineProperty` (Array.isArray) so
  we don't penalize every defineProperty for doing that.
- Only revalidate observers once per mixin application.
- Only brand check `didDefineProperty` once per mixin application.
- Replace `for..in` loops with `Object.keys` since we only care about
  own properties.
- Only loop once in `extractAccessors`.
- Combine observer and listener meta into a single object so we only
  need to do one lookup. In most cases, this is undefined in modern
  applications, so no extra memory cost.
- Simplify CP descriptor property lookups (remove duplicate functions).

(cherry picked from commit f77f5a4)
  • Loading branch information
Chris Garrett authored and rwjblue committed Aug 10, 2020
1 parent 20bf2aa commit f994a52
Show file tree
Hide file tree
Showing 13 changed files with 576 additions and 679 deletions.
4 changes: 1 addition & 3 deletions packages/@ember/-internals/metal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ export {
DecoratorPropertyDescriptor,
isElementDescriptor,
nativeDescDecorator,
} from './lib/decorator';
export {
descriptorForDecorator,
descriptorForProperty,
isClassicDecorator,
setClassicDecorator,
} from './lib/descriptor_map';
} from './lib/decorator';
export { default as libraries, Libraries } from './lib/libraries';
export { default as getProperties } from './lib/get_properties';
export { default as setProperties } from './lib/set_properties';
Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/-internals/metal/lib/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import { finishLazyChains, getChainTagsForKey } from './chain-tags';
import {
ComputedDescriptor,
Decorator,
descriptorForDecorator,
isElementDescriptor,
makeComputedDecorator,
} from './decorator';
import { descriptorForDecorator } from './descriptor_map';
import { defineProperty } from './properties';
import { get } from './property_get';
import { set } from './property_set';
Expand Down
Loading

0 comments on commit f994a52

Please sign in to comment.