Skip to content

Commit 5a3ae6c

Browse files
author
Brian Vaughn
committed
Small variable naming cleanup in Store
1 parent 7e149e8 commit 5a3ae6c

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

packages/react-devtools-shared/src/devtools/store.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default class Store extends EventEmitter<{|
9393
// Map of ID to number of recorded error and warning message IDs.
9494
_errorsAndWarnings: Map<
9595
number,
96-
{errors: number, warnings: number},
96+
{|errorCount: number, warningCount: number|},
9797
> = new Map();
9898

9999
// At least one of the injected renderers contains (DEV only) owner metadata.
@@ -490,15 +490,7 @@ export default class Store extends EventEmitter<{|
490490
getErrorAndWarningCountForElementID(
491491
id: number,
492492
): {|errorCount: number, warningCount: number|} {
493-
const map = this._errorsAndWarnings.get(id);
494-
if (map != null) {
495-
return {
496-
errorCount: map.errors,
497-
warningCount: map.warnings,
498-
};
499-
} else {
500-
return {errorCount: 0, warningCount: 0};
501-
}
493+
return this._errorsAndWarnings.get(id) || {errorCount: 0, warningCount: 0};
502494
}
503495

504496
getIndexOfElementID(id: number): number | null {
@@ -1071,16 +1063,13 @@ export default class Store extends EventEmitter<{|
10711063
break;
10721064
case TREE_OPERATION_UPDATE_ERRORS_OR_WARNINGS:
10731065
const id = operations[i + 1];
1074-
const numErrors = operations[i + 2];
1075-
const numWarnings = operations[i + 3];
1066+
const errorCount = operations[i + 2];
1067+
const warningCount = operations[i + 3];
10761068

10771069
i += 4;
10781070

1079-
if (numErrors > 0 || numWarnings > 0) {
1080-
this._errorsAndWarnings.set(id, {
1081-
errors: numErrors,
1082-
warnings: numWarnings,
1083-
});
1071+
if (errorCount > 0 || warningCount > 0) {
1072+
this._errorsAndWarnings.set(id, {errorCount, warningCount});
10841073
} else if (this._errorsAndWarnings.has(id)) {
10851074
this._errorsAndWarnings.delete(id);
10861075
}
@@ -1097,9 +1086,9 @@ export default class Store extends EventEmitter<{|
10971086
let errorCount = 0;
10981087
let warningCount = 0;
10991088

1100-
this._errorsAndWarnings.forEach(({errors, warnings}) => {
1101-
errorCount += errors;
1102-
warningCount += warnings;
1089+
this._errorsAndWarnings.forEach(entry => {
1090+
errorCount += entry.errorCount;
1091+
warningCount += entry.warningCount;
11031092
});
11041093

11051094
this._cachedErrorCount = errorCount;

packages/react-devtools-shared/src/devtools/utils.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ export function printStore(
9393
} else {
9494
const errorsAndWarnings = store._errorsAndWarnings;
9595
if (errorsAndWarnings.size > 0) {
96-
let errorsSum = 0;
97-
let warningsSum = 0;
98-
errorsAndWarnings.forEach(({errors, warnings}) => {
99-
errorsSum += errors;
100-
warningsSum += warnings;
96+
let errorCount = 0;
97+
let warningCount = 0;
98+
errorsAndWarnings.forEach(entry => {
99+
errorCount += entry.errorCount;
100+
warningCount += entry.warningCount;
101101
});
102102

103-
snapshotLines.push(`✕ ${errorsSum}, ⚠ ${warningsSum}`);
103+
snapshotLines.push(`✕ ${errorCount}, ⚠ ${warningCount}`);
104104
}
105105

106106
store.roots.forEach(rootID => {

0 commit comments

Comments
 (0)