Skip to content

Commit

Permalink
Renamed serialized *Map keys to *KeyValueArray for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Jan 28, 2022
1 parent d9a557d commit 1154a73
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ Object {
],
"timelineData": Array [
Object {
"batchUIDToMeasuresMap": Array [
"batchUIDToMeasuresKeyValueArray": Array [
Array [
1,
Array [
Expand Down Expand Up @@ -1086,7 +1086,7 @@ Object {
"duration": 65,
"flamechart": Array [],
"internalModuleSourceToRanges": Array [],
"laneToLabelMap": Array [
"laneToLabelKeyValueArray": Array [
Array [
1,
"Sync",
Expand Down Expand Up @@ -1212,7 +1212,7 @@ Object {
"Offscreen",
],
],
"laneToReactMeasureMap": Array [
"laneToReactMeasureKeyValueArray": Array [
Array [
1,
Array [
Expand Down Expand Up @@ -1985,7 +1985,7 @@ Object {
],
"timelineData": Array [
Object {
"batchUIDToMeasuresMap": Array [
"batchUIDToMeasuresKeyValueArray": Array [
Array [
1,
Array [
Expand Down Expand Up @@ -2173,7 +2173,7 @@ Object {
"duration": 55,
"flamechart": Array [],
"internalModuleSourceToRanges": Array [],
"laneToLabelMap": Array [
"laneToLabelKeyValueArray": Array [
Array [
1,
"Sync",
Expand Down Expand Up @@ -2299,7 +2299,7 @@ Object {
"Offscreen",
],
],
"laneToReactMeasureMap": Array [
"laneToReactMeasureKeyValueArray": Array [
Array [
1,
Array [
Expand Down Expand Up @@ -3507,7 +3507,7 @@ Object {
],
"timelineData": Array [
Object {
"batchUIDToMeasuresMap": Array [
"batchUIDToMeasuresKeyValueArray": Array [
Array [
1,
Array [
Expand Down Expand Up @@ -3793,7 +3793,7 @@ Object {
"duration": 64,
"flamechart": Array [],
"internalModuleSourceToRanges": Array [],
"laneToLabelMap": Array [
"laneToLabelKeyValueArray": Array [
Array [
1,
"Sync",
Expand Down Expand Up @@ -3919,7 +3919,7 @@ Object {
"Offscreen",
],
],
"laneToReactMeasureMap": Array [
"laneToReactMeasureKeyValueArray": Array [
Array [
1,
Array [
Expand Down Expand Up @@ -5042,7 +5042,7 @@ Object {
],
"timelineData": Array [
Object {
"batchUIDToMeasuresMap": Array [
"batchUIDToMeasuresKeyValueArray": Array [
Array [
1,
Array [
Expand Down Expand Up @@ -5295,7 +5295,7 @@ Object {
"duration": 20,
"flamechart": Array [],
"internalModuleSourceToRanges": Array [],
"laneToLabelMap": Array [
"laneToLabelKeyValueArray": Array [
Array [
1,
"Sync",
Expand Down Expand Up @@ -5421,7 +5421,7 @@ Object {
"Offscreen",
],
],
"laneToReactMeasureMap": Array [
"laneToReactMeasureKeyValueArray": Array [
Array [
1,
Array [
Expand Down Expand Up @@ -7059,7 +7059,7 @@ Object {
],
"timelineData": Array [
Object {
"batchUIDToMeasuresMap": Array [
"batchUIDToMeasuresKeyValueArray": Array [
Array [
1,
Array [
Expand Down Expand Up @@ -7394,7 +7394,7 @@ Object {
"duration": 20,
"flamechart": Array [],
"internalModuleSourceToRanges": Array [],
"laneToLabelMap": Array [
"laneToLabelKeyValueArray": Array [
Array [
1,
"Sync",
Expand Down Expand Up @@ -7520,7 +7520,7 @@ Object {
"Offscreen",
],
],
"laneToReactMeasureMap": Array [
"laneToReactMeasureKeyValueArray": Array [
Array [
1,
Array [
Expand Down
10 changes: 7 additions & 3 deletions packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3999,12 +3999,16 @@ export function attach(
// but we need to convert the nested Arrays back to Maps.
// Most of the data is safe to serialize as-is,
// but we need to convert the Maps to nested Arrays.
batchUIDToMeasuresMap: Array.from(batchUIDToMeasuresMap.entries()),
batchUIDToMeasuresKeyValueArray: Array.from(
batchUIDToMeasuresMap.entries(),
),
internalModuleSourceToRanges: Array.from(
internalModuleSourceToRanges.entries(),
),
laneToLabelMap: Array.from(laneToLabelMap.entries()),
laneToReactMeasureMap: Array.from(laneToReactMeasureMap.entries()),
laneToLabelKeyValueArray: Array.from(laneToLabelMap.entries()),
laneToReactMeasureKeyValueArray: Array.from(
laneToReactMeasureMap.entries(),
),
};
}
}
Expand Down
34 changes: 19 additions & 15 deletions packages/react-devtools-shared/src/devtools/views/Profiler/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export function prepareProfilingDataFrontendFromBackendAndStore(
const {timelineData} = dataBackend;
if (timelineData != null) {
const {
batchUIDToMeasuresMap,
batchUIDToMeasuresKeyValueArray,
internalModuleSourceToRanges,
laneToLabelMap,
laneToReactMeasureMap,
laneToLabelKeyValueArray,
laneToReactMeasureKeyValueArray,
...rest
} = timelineData;

Expand All @@ -63,10 +63,10 @@ export function prepareProfilingDataFrontendFromBackendAndStore(

// Most of the data is safe to parse as-is,
// but we need to convert the nested Arrays back to Maps.
batchUIDToMeasuresMap: new Map(batchUIDToMeasuresMap),
batchUIDToMeasuresMap: new Map(batchUIDToMeasuresKeyValueArray),
internalModuleSourceToRanges: new Map(internalModuleSourceToRanges),
laneToLabelMap: new Map(laneToLabelMap),
laneToReactMeasureMap: new Map(laneToReactMeasureMap),
laneToLabelMap: new Map(laneToLabelKeyValueArray),
laneToReactMeasureMap: new Map(laneToReactMeasureKeyValueArray),
});
}

Expand Down Expand Up @@ -154,13 +154,13 @@ export function prepareProfilingDataFrontendFromExport(
const timelineData: Array<TimelineData> = profilingDataExport.timelineData
? profilingDataExport.timelineData.map(
({
batchUIDToMeasuresMap,
batchUIDToMeasuresKeyValueArray,
componentMeasures,
duration,
flamechart,
internalModuleSourceToRanges,
laneToLabelMap,
laneToReactMeasureMap,
laneToLabelKeyValueArray,
laneToReactMeasureKeyValueArray,
nativeEvents,
networkMeasures,
otherUserTimingMarks,
Expand All @@ -174,13 +174,13 @@ export function prepareProfilingDataFrontendFromExport(
}) => ({
// Most of the data is safe to parse as-is,
// but we need to convert the nested Arrays back to Maps.
batchUIDToMeasuresMap: new Map(batchUIDToMeasuresMap),
batchUIDToMeasuresMap: new Map(batchUIDToMeasuresKeyValueArray),
componentMeasures,
duration,
flamechart,
internalModuleSourceToRanges: new Map(internalModuleSourceToRanges),
laneToLabelMap: new Map(laneToLabelMap),
laneToReactMeasureMap: new Map(laneToReactMeasureMap),
laneToLabelMap: new Map(laneToLabelKeyValueArray),
laneToReactMeasureMap: new Map(laneToReactMeasureKeyValueArray),
nativeEvents,
networkMeasures,
otherUserTimingMarks,
Expand Down Expand Up @@ -272,15 +272,19 @@ export function prepareProfilingDataExport(
}) => ({
// Most of the data is safe to serialize as-is,
// but we need to convert the Maps to nested Arrays.
batchUIDToMeasuresMap: Array.from(batchUIDToMeasuresMap.entries()),
batchUIDToMeasuresKeyValueArray: Array.from(
batchUIDToMeasuresMap.entries(),
),
componentMeasures: componentMeasures,
duration,
flamechart,
internalModuleSourceToRanges: Array.from(
internalModuleSourceToRanges.entries(),
),
laneToLabelMap: Array.from(laneToLabelMap.entries()),
laneToReactMeasureMap: Array.from(laneToReactMeasureMap.entries()),
laneToLabelKeyValueArray: Array.from(laneToLabelMap.entries()),
laneToReactMeasureKeyValueArray: Array.from(
laneToReactMeasureMap.entries(),
),
nativeEvents,
networkMeasures,
otherUserTimingMarks,
Expand Down
6 changes: 3 additions & 3 deletions packages/react-devtools-timeline/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,15 @@ export type TimelineData = {|
|};

export type TimelineDataExport = {|
batchUIDToMeasuresMap: Array<[BatchUID, ReactMeasure[]]>,
batchUIDToMeasuresKeyValueArray: Array<[BatchUID, ReactMeasure[]]>,
componentMeasures: ReactComponentMeasure[],
duration: number,
flamechart: Flamechart,
internalModuleSourceToRanges: Array<
[string, Array<[ErrorStackFrame, ErrorStackFrame]>],
>,
laneToLabelMap: Array<[ReactLane, string]>,
laneToReactMeasureMap: Array<[ReactLane, ReactMeasure[]]>,
laneToLabelKeyValueArray: Array<[ReactLane, string]>,
laneToReactMeasureKeyValueArray: Array<[ReactLane, ReactMeasure[]]>,
nativeEvents: NativeEvent[],
networkMeasures: NetworkMeasure[],
otherUserTimingMarks: UserTimingMark[],
Expand Down

0 comments on commit 1154a73

Please sign in to comment.