Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Refine reset checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Dec 24, 2016
1 parent 13ccb9a commit 4d02be0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -1468,9 +1468,8 @@
destination = data.destination,
currValue = destination[key];

// Skip pseudo private properties like `_timerId` which could be a
// Java object in environments like RingoJS.
if (key.charAt(0) == '_') {
// Skip pseudo private properties and event listeners.
if (/^_|^events$|^on[A-Z]/.test(key)) {
return;
}
if (_.isObjectLike(value)) {
Expand All @@ -1481,7 +1480,7 @@
currValue = [];
}
// Check if an array has changed its length.
else if (currValue.length != value.length) {
if (currValue.length != value.length) {
changed = true;
currValue = currValue.slice(0, value.length);
currValue.length = value.length;
Expand All @@ -1499,15 +1498,16 @@
queue.push({ 'destination': currValue, 'source': value });
}
// Register a changed primitive.
else if (value !== currValue && !(value == null || _.isFunction(value))) {
else if (!_.eq(currValue, value) && value !== undefined) {
changes.push({ 'destination': destination, 'key': key, 'value': value });
}
});
}
while ((data = queue[index++]));

// If changed emit the `reset` event and if it isn't cancelled reset the benchmark.
if (changes.length && (bench.emit(event = Event('reset')), !event.cancelled)) {
if (changes.length &&
(bench.emit(event = Event('reset')), !event.cancelled)) {
_.each(changes, function(data) {
data.destination[data.key] = data.value;
});
Expand Down

0 comments on commit 4d02be0

Please sign in to comment.