Skip to content

Commit 2045214

Browse files
committed
Rename source table uuid field to id
The name of this field doesn't make sense anymore as we changed its value from UUID to a hash value. This `id` name is more implementation agnostic, so it's better to rename it now. Note that this requires an upgrader, similar to the previous patches in this patch stack. The upgrader will happen in the last commit with all the relevant changes.
1 parent 0af72e8 commit 2045214

20 files changed

Lines changed: 216 additions & 216 deletions

src/components/app/SourceCodeFetcher.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
getSymbolServerUrl,
1212
getSourceViewFile,
1313
getSourceViewSourceIndex,
14-
getSourceViewSourceUuid,
14+
getSourceViewSourceId,
1515
} from 'firefox-profiler/selectors';
1616
import {
1717
beginLoadingSourceCodeFromUrl,
@@ -36,7 +36,7 @@ import type {
3636
type StateProps = {
3737
readonly sourceViewFile: string | null;
3838
readonly sourceViewSourceIndex: IndexIntoSourceTable | null;
39-
readonly sourceViewSourceUuid: string | null;
39+
readonly sourceViewSourceId: string | null;
4040
readonly sourceViewCode: SourceCodeStatus | void;
4141
readonly symbolServerUrl: string;
4242
readonly profile: Profile | null;
@@ -68,7 +68,7 @@ class SourceCodeFetcherImpl extends React.PureComponent<Props> {
6868
sourceViewSourceIndex,
6969
sourceViewCode,
7070
sourceViewFile,
71-
sourceViewSourceUuid,
71+
sourceViewSourceId,
7272
beginLoadingSourceCodeFromUrl,
7373
beginLoadingSourceCodeFromBrowserConnection,
7474
finishLoadingSourceCode,
@@ -105,7 +105,7 @@ class SourceCodeFetcherImpl extends React.PureComponent<Props> {
105105

106106
const fetchSourceResult = await fetchSource(
107107
sourceViewFile,
108-
sourceViewSourceUuid,
108+
sourceViewSourceId,
109109
symbolServerUrl,
110110
addressProof,
111111
this._archiveCache,
@@ -137,7 +137,7 @@ export const SourceCodeFetcher = explicitConnect<{}, StateProps, DispatchProps>(
137137
mapStateToProps: (state) => ({
138138
sourceViewSourceIndex: getSourceViewSourceIndex(state),
139139
sourceViewFile: getSourceViewFile(state),
140-
sourceViewSourceUuid: getSourceViewSourceUuid(state),
140+
sourceViewSourceId: getSourceViewSourceId(state),
141141
sourceViewCode: getSourceViewCode(state),
142142
symbolServerUrl: getSymbolServerUrl(state),
143143
profile: getProfileOrNull(state),

src/profile-logic/data-structures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ export function getEmptySourceTable(): SourceTable {
348348
// If modifying this structure, please update all callers of this function to ensure
349349
// that they are pushing on correctly to the data structure. These pushes may not
350350
// be caught by the type system.
351-
uuid: [],
351+
id: [],
352352
filename: [],
353353
startLine: [],
354354
startColumn: [],

src/profile-logic/global-data-collector.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class GlobalDataCollector {
6161
_libNameToResourceIndex: Map<IndexIntoStringTable, IndexIntoResourceTable> =
6262
new Map();
6363
_originToResourceIndex: Map<string, IndexIntoResourceTable> = new Map();
64-
_uuidToSourceIndex: Map<string, IndexIntoSourceTable> = new Map();
64+
_idToSourceIndex: Map<string, IndexIntoSourceTable> = new Map();
6565
_filenameToSourceIndex: Map<IndexIntoStringTable, IndexIntoSourceTable> =
6666
new Map();
6767

@@ -116,18 +116,18 @@ export class GlobalDataCollector {
116116
// Return the global index for this source, adding it to the global list if
117117
// necessary.
118118
indexForSource(
119-
uuid: string | null,
119+
id: string | null,
120120
filename: string,
121121
startLine: number = 1,
122122
startColumn: number = 1,
123123
sourceMapURL: string | null = null
124124
): IndexIntoSourceTable {
125125
let index: IndexIntoSourceTable | undefined;
126126

127-
if (uuid !== null) {
128-
index = this._uuidToSourceIndex.get(uuid);
127+
if (id !== null) {
128+
index = this._idToSourceIndex.get(id);
129129
} else {
130-
// For null UUIDs, use filename-based lookup.
130+
// For null IDs, use filename-based lookup.
131131
const filenameIndex = this._stringTable.indexForString(filename);
132132
index = this._filenameToSourceIndex.get(filenameIndex);
133133
}
@@ -139,15 +139,15 @@ export class GlobalDataCollector {
139139
sourceMapURL !== null
140140
? this._stringTable.indexForString(sourceMapURL)
141141
: null;
142-
this._sources.uuid[index] = uuid;
142+
this._sources.id[index] = id;
143143
this._sources.filename[index] = filenameIndex;
144144
this._sources.startLine[index] = startLine;
145145
this._sources.startColumn[index] = startColumn;
146146
this._sources.sourceMapURL[index] = sourceMapURLIndex;
147147
this._sources.length++;
148148

149-
if (uuid !== null) {
150-
this._uuidToSourceIndex.set(uuid, index);
149+
if (id !== null) {
150+
this._idToSourceIndex.set(id, index);
151151
} else {
152152
this._filenameToSourceIndex.set(filenameIndex, index);
153153
}

src/profile-logic/merge-compare.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ function mergeSources(
556556
const oldStringToNewStringPlusOne = translationMapsForStrings[profileIndex];
557557

558558
for (let i = 0; i < sources.length; i++) {
559-
const uuid = sources.uuid[i];
559+
const id = sources.id[i];
560560
const originalUrlIndex = sources.filename[i];
561561
const newUrlIndex = oldStringToNewStringPlusOne[originalUrlIndex] - 1;
562562

@@ -566,12 +566,12 @@ function mergeSources(
566566
? oldStringToNewStringPlusOne[originalSourceMapURLIndex] - 1
567567
: null;
568568

569-
const sourceKey = uuid ?? `null-uuid-${newUrlIndex}`;
569+
const sourceKey = id ?? `null-id-${newUrlIndex}`;
570570
let insertedSourceIndex = mapOfInsertedSources.get(sourceKey);
571571
if (insertedSourceIndex === undefined) {
572572
// Add new source
573573
insertedSourceIndex = newSources.length;
574-
newSources.uuid[insertedSourceIndex] = uuid;
574+
newSources.id[insertedSourceIndex] = id;
575575
newSources.filename[insertedSourceIndex] = newUrlIndex;
576576
newSources.startLine[insertedSourceIndex] = sources.startLine[i];
577577
newSources.startColumn[insertedSourceIndex] = sources.startColumn[i];

src/profile-logic/process-profile.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,22 +431,22 @@ function _extractJsFunction(
431431
let processedSourceIndex = null;
432432
if (sourceIndex !== undefined) {
433433
const geckoSourceIdx = parseInt(sourceIndex, 10);
434-
// Look up the UUID for this source index from the process's sources table.
434+
// Look up the ID for this source index from the process's sources table.
435435
if (geckoSourceIdx < geckoSourceTable.data.length) {
436-
const uuidIndex = geckoSourceTable.schema.uuid;
436+
const idIndex = geckoSourceTable.schema.id;
437437
const filenameIndex = geckoSourceTable.schema.filename;
438438
const startLineIndex = geckoSourceTable.schema.startLine;
439439
const startColumnIndex = geckoSourceTable.schema.startColumn;
440440
const sourceMapURLIndex = geckoSourceTable.schema.sourceMapURL;
441-
const uuid = geckoSourceTable.data[geckoSourceIdx][uuidIndex];
441+
const id = geckoSourceTable.data[geckoSourceIdx][idIndex];
442442
const filename = geckoSourceTable.data[geckoSourceIdx][filenameIndex];
443443
const startLine = geckoSourceTable.data[geckoSourceIdx][startLineIndex];
444444
const startColumn =
445445
geckoSourceTable.data[geckoSourceIdx][startColumnIndex];
446446
const sourceMapURL =
447447
geckoSourceTable.data[geckoSourceIdx][sourceMapURLIndex];
448448
processedSourceIndex = globalDataCollector.indexForSource(
449-
uuid,
449+
id,
450450
filename,
451451
startLine,
452452
startColumn,

src/profile-logic/processed-profile-versioning.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,7 +2663,7 @@ const _upgraders: {
26632663
// Create the sources table
26642664
const sourceTable = {
26652665
length: 0,
2666-
uuid: [] as Array<string | null>,
2666+
id: [] as Array<string | null>,
26672667
filename: [] as Array<number>,
26682668
};
26692669

@@ -2690,7 +2690,7 @@ const _upgraders: {
26902690
if (sourceIndex === undefined) {
26912691
// Add new entry to sources table
26922692
sourceIndex = sourceTable.length;
2693-
sourceTable.uuid.push(null);
2693+
sourceTable.id.push(null);
26942694
sourceTable.filename.push(fileNameIndex);
26952695
sourceTable.length++;
26962696
fileNameIndexToSourceIndex.set(fileNameIndex, sourceIndex);

src/profile-logic/profile-compacting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ function _createCompactedSources(
770770
const newIndex = newSources.length++;
771771
newSources.filename[newIndex] =
772772
oldStringToNewStringPlusOne[sources.filename[i]] - 1;
773-
newSources.uuid[newIndex] = sources.uuid[i];
773+
newSources.id[newIndex] = sources.id[i];
774774
newSources.startLine[newIndex] = sources.startLine[i];
775775
newSources.startColumn[newIndex] = sources.startColumn[i];
776776

src/profile-logic/symbolication.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ function _partiallyApplySymbolicationStep(
806806
for (let i = 0; i < sources.filename.length; i++) {
807807
if (
808808
sources.filename[i] === fileNameStringIndex &&
809-
sources.uuid[i] === null
809+
sources.id[i] === null
810810
) {
811811
sourceIndex = i;
812812
break;
@@ -815,7 +815,7 @@ function _partiallyApplySymbolicationStep(
815815
if (sourceIndex === null) {
816816
sourceIndex = sources.filename.length;
817817
sources.filename.push(fileNameStringIndex);
818-
sources.uuid.push(null);
818+
sources.id.push(null);
819819
sources.startLine.push(1);
820820
sources.startColumn.push(1);
821821
sources.sourceMapURL.push(null);

src/selectors/profile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -963,9 +963,9 @@ export const getSourceViewFile: Selector<string | null> = createSelector(
963963
}
964964
);
965965

966-
export const getSourceViewSourceUuid: Selector<string | null> = createSelector(
966+
export const getSourceViewSourceId: Selector<string | null> = createSelector(
967967
getSourceTable,
968968
UrlState.getSourceViewSourceIndex,
969969
(sources, sourceIndex) =>
970-
sourceIndex !== null ? sources.uuid[sourceIndex] : null
970+
sourceIndex !== null ? sources.id[sourceIndex] : null
971971
);

src/test/fixtures/profiles/gecko-profile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function getEmptyMarkers(): GeckoMarkers {
4949
export function getEmptySourceTable(): GeckoSourceTable {
5050
return {
5151
schema: {
52-
uuid: 0 as const,
52+
id: 0 as const,
5353
filename: 1 as const,
5454
startLine: 2 as const,
5555
startColumn: 3 as const,

0 commit comments

Comments
 (0)