-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BUGFIX canary] Meta refactor #11966
Merged
Merged
Changes from 32 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
a5dcce8
DRY up meta()
ef4 8133291
moving meta into its own module
ef4 3044547
make exports consistent
ef4 ab25153
notes-to-self on each meta property's access patterns
ef4 807b963
encapsulated meta.cache
ef4 31c16f0
generalize upgrade support
ef4 4bb9009
more progress on generic meta accessors
ef4 d885f23
encapsulated meta.watching
ef4 542765b
align semantics
ef4 a4c9dd3
lazy watchers
ef4 68895ec
encapsulated meta.mixins
ef4 aab8f9a
encapsulate meta.bindings
ef4 0b96990
encapsulated meta.values
ef4 bbfb0e7
typos
ef4 c40512a
extra reusable bits
ef4 bab0092
encapsulate meta.listeners
ef4 9b51c9e
encapsulate meta.deps
ef4 1fd3eb5
encapsulate meta.chainWatchers
ef4 a3f86cc
encapsulate meta.chains
ef4 93743c1
break the meta prototype chain!
ef4 d51a492
better naming
ef4 f216afc
better naming for inheritedMap accessors
ef4 a4a4854
better naming for inheritMapOfLists accessors
ef4 2d70d56
better naming for inheritedMapOfMaps accessors
ef4 d748879
better naming for ownCustomObject accessors
ef4 dbc712c
better naming for inheritedCustomObject accessors
ef4 8886eb7
commenting
ef4 45d73c1
spelling, how does it work?
ef4 26008e0
starting some new meta tests
ef4 c4b3bce
point everything at the new meta module
ef4 71ebf9c
fancy new listener data structures
ef4 84a0a50
remove outdated comment
ef4 7b5fcc0
micro-optimize every Object.create(null) to our own EmptyObject
ef4 c64b316
fix silly unnecessary defProp
ef4 09218cf
incorporating stef feedback
ef4 714f0b8
use empty object
ef4 580a40a
speed up Meta instantiation
stefanpenner a64e211
don’t event try the for loop if there are no actions
stefanpenner b6b0739
remove get for an internal property that will never be a CP
stefanpenner 584fc73
Merge pull request #2 from stefanpenner/eds
ef4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import Ember from 'ember-metal/core'; | ||
import { set } from 'ember-metal/property_set'; | ||
import { | ||
meta, | ||
inspect | ||
} from 'ember-metal/utils'; | ||
import { inspect } from 'ember-metal/utils'; | ||
import { meta } from 'ember-metal/meta'; | ||
import expandProperties from 'ember-metal/expand_properties'; | ||
import EmberError from 'ember-metal/error'; | ||
import { | ||
|
@@ -266,9 +264,10 @@ ComputedPropertyPrototype.didChange = function(obj, keyName) { | |
// _suspended is set via a CP.set to ensure we don't clear | ||
// the cached value set by the setter | ||
if (this._cacheable && this._suspended !== obj) { | ||
var meta = metaFor(obj); | ||
if (meta.cache && meta.cache[keyName] !== undefined) { | ||
meta.cache[keyName] = undefined; | ||
let meta = metaFor(obj); | ||
let cache = meta.readableCache(); | ||
if (cache && cache[keyName] !== undefined) { | ||
cache[keyName] = undefined; | ||
removeDependentKeys(this, obj, keyName, meta); | ||
} | ||
} | ||
|
@@ -305,9 +304,9 @@ ComputedPropertyPrototype.get = function(obj, keyName) { | |
var ret, cache, meta; | ||
if (this._cacheable) { | ||
meta = metaFor(obj); | ||
cache = meta.cache; | ||
cache = meta.writableCache(); | ||
|
||
var result = cache && cache[keyName]; | ||
var result = cache[keyName]; | ||
|
||
if (result === UNDEFINED) { | ||
return undefined; | ||
|
@@ -316,18 +315,16 @@ ComputedPropertyPrototype.get = function(obj, keyName) { | |
} | ||
|
||
ret = this._getter.call(obj, keyName); | ||
cache = meta.cache; | ||
if (!cache) { | ||
cache = meta.cache = {}; | ||
} | ||
|
||
if (ret === undefined) { | ||
cache[keyName] = UNDEFINED; | ||
} else { | ||
cache[keyName] = ret; | ||
} | ||
|
||
if (meta.chainWatchers) { | ||
meta.chainWatchers.revalidate(keyName); | ||
let chainWatchers = meta.readableChainWatchers(); | ||
if (chainWatchers) { | ||
chainWatchers.revalidate(keyName); | ||
} | ||
addDependentKeys(this, obj, keyName, meta); | ||
} else { | ||
|
@@ -401,7 +398,7 @@ ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, valu | |
var cacheable = this._cacheable; | ||
var setter = this._setter; | ||
var meta = metaFor(obj, cacheable); | ||
var cache = meta.cache; | ||
var cache = meta.readableCache(); | ||
var hadCachedValue = false; | ||
|
||
var cachedValue, ret; | ||
|
@@ -427,7 +424,7 @@ ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, valu | |
|
||
if (hadCachedValue && cachedValue === ret) { return; } | ||
|
||
var watched = meta.watching[keyName]; | ||
var watched = meta.peekWatching(keyName); | ||
if (watched) { | ||
propertyWillChange(obj, keyName); | ||
} | ||
|
@@ -441,7 +438,7 @@ ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, valu | |
addDependentKeys(this, obj, keyName, meta); | ||
} | ||
if (!cache) { | ||
cache = meta.cache = {}; | ||
cache = meta.writableCache(); | ||
} | ||
if (ret === undefined) { | ||
cache[keyName] = UNDEFINED; | ||
|
@@ -460,13 +457,13 @@ ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, valu | |
/* called before property is overridden */ | ||
ComputedPropertyPrototype.teardown = function(obj, keyName) { | ||
var meta = metaFor(obj); | ||
|
||
if (meta.cache) { | ||
if (keyName in meta.cache) { | ||
let cache = meta.readableCache(); | ||
if (cache) { | ||
if (keyName in cache) { | ||
removeDependentKeys(this, obj, keyName, meta); | ||
} | ||
|
||
if (this._cacheable) { delete meta.cache[keyName]; } | ||
if (this._cacheable) { delete cache[keyName]; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. given the above it my be worth investigating |
||
} | ||
|
||
return null; // no value to restore | ||
|
@@ -560,7 +557,7 @@ export default function computed(func) { | |
*/ | ||
function cacheFor(obj, key) { | ||
var meta = obj['__ember_meta__']; | ||
var cache = meta && meta.cache; | ||
var cache = meta && meta.readableCache(); | ||
var ret = cache && cache[key]; | ||
|
||
if (ret === UNDEFINED) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I recall, the cache will never have an undefined member representing the value of undefined, rather it will use the UNDEFINED sentinel value. This means, we can likely just do (the unfortunately faster)
if (cache[keyName] !== undefined)