Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit cd12922

Browse files
committed
perf: optimize binding equals performance.
The angular watch function is already fetching the scope value, so there is no need to fetch it again inside equals. Also the symantics of `angular.equals()` is such that filtering the properties with `$firebaseUtils.scopeData()` before passing to `angular.equals()` is unnecessary.
1 parent b1ec35b commit cd12922

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/FirebaseObject.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,10 @@
318318
self.scope = scope;
319319
self.varName = varName;
320320

321-
function equals(rec) {
322-
var parsed = getScope();
323-
var newData = $firebaseUtils.scopeData(rec);
324-
return angular.equals(parsed, newData) &&
325-
parsed.$priority === rec.$priority &&
326-
parsed.$value === rec.$value;
321+
function equals(scopeValue) {
322+
return angular.equals(scopeValue, rec) &&
323+
scopeValue.$priority === rec.$priority &&
324+
scopeValue.$value === rec.$value;
327325
}
328326

329327
function getScope() {
@@ -339,15 +337,15 @@
339337
['finally'](function() { sending = false; });
340338
}, 50, 500);
341339

342-
var scopeUpdated = function() {
343-
if( !equals(rec) ) {
340+
var scopeUpdated = function(newVal) {
341+
if( !equals(newVal[0]) ) {
344342
sending = true;
345343
send();
346344
}
347345
};
348346

349347
var recUpdated = function() {
350-
if( !sending && !equals(rec) ) {
348+
if( !sending && !equals(parsed(scope)) ) {
351349
setScope(rec);
352350
}
353351
};

0 commit comments

Comments
 (0)