Skip to content

Commit

Permalink
Remove getMarkerSchemaName and the now-unused marker name argument fr…
Browse files Browse the repository at this point in the history
…om getSchemaFromMarker.
  • Loading branch information
mstange committed Jan 6, 2025
1 parent ac1c2b6 commit 02732bf
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 83 deletions.
13 changes: 2 additions & 11 deletions src/actions/receive-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
getRelevantPagesForActiveTab,
getSymbolServerUrl,
getActiveTabID,
getMarkerSchemaByName,
} from 'firefox-profiler/selectors';
import {
getSelectedTab,
Expand Down Expand Up @@ -321,11 +320,7 @@ export function finalizeFullProfileView(
tabFilter,
tabToThreadIndexesMap
);
const localTracksByPid = computeLocalTracksByPid(
profile,
globalTracks,
getMarkerSchemaByName(getState())
);
const localTracksByPid = computeLocalTracksByPid(profile, globalTracks);

const legacyThreadOrder = getLegacyThreadOrder(getState());
const globalTrackOrder = initializeGlobalTrackOrder(
Expand Down Expand Up @@ -1835,11 +1830,7 @@ export function changeTabFilter(tabID: TabID | null): ThunkAction<void> {
tabID,
tabToThreadIndexesMap
);
const localTracksByPid = computeLocalTracksByPid(
profile,
globalTracks,
getMarkerSchemaByName(getState())
);
const localTracksByPid = computeLocalTracksByPid(profile, globalTracks);

const legacyThreadOrder = getLegacyThreadOrder(getState());
const globalTrackOrder = initializeGlobalTrackOrder(
Expand Down
6 changes: 1 addition & 5 deletions src/components/tooltip/Marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,7 @@ class MarkerTooltipContents extends React.PureComponent<Props> {

if (data) {
// Add the details for the markers based on their Marker schema.
const schema = getSchemaFromMarker(
markerSchemaByName,
marker.name,
marker.data
);
const schema = getSchemaFromMarker(markerSchemaByName, marker.data);
if (schema) {
for (const schemaData of schema.data) {
// Check for a schema that is looking up and formatting a value from
Expand Down
25 changes: 5 additions & 20 deletions src/profile-logic/marker-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
INTERVAL_END,
} from 'firefox-profiler/app-logic/constants';
import {
getMarkerSchemaName,
getSchemaFromMarker,
markerPayloadMatchesSearch,
} from './marker-schema';
Expand Down Expand Up @@ -226,11 +225,7 @@ function positiveFilterMarker(
}

// Now check the schema for the marker payload for searchable
const markerSchema = getSchemaFromMarker(
markerSchemaByName,
marker.name,
marker.data
);
const markerSchema = getSchemaFromMarker(markerSchemaByName, marker.data);
if (
markerSchema &&
markerPayloadMatchesSearch(markerSchema, marker, stringTable, test)
Expand Down Expand Up @@ -292,11 +287,7 @@ function negativeFilterMarker(
}

// Now check the schema for the marker payload for searchable
const markerSchema = getSchemaFromMarker(
markerSchemaByName,
marker.name,
marker.data
);
const markerSchema = getSchemaFromMarker(markerSchemaByName, marker.data);

if (
markerSchema &&
Expand Down Expand Up @@ -1287,14 +1278,12 @@ export function getAllowMarkersWithNoSchema(
const { data } = marker;

if (!data) {
// Keep the marker if there is payload.
// Keep the marker if there is no payload.
return true;
}

if (!markerSchemaByName[data.type]) {
// Keep the marker if there is no schema. Note that this function doesn't use
// the getMarkerSchemaName function, as that function attempts to find a
// marker schema name in a very permissive manner. In the marker chart
// Keep the marker if there is no schema. In the marker chart
// and marker table, most likely we want to show everything.
return true;
}
Expand Down Expand Up @@ -1528,11 +1517,7 @@ export function filterMarkerByDisplayLocation(
return additionalResult;
}

const schemaName = getMarkerSchemaName(
markerSchemaByName,
marker.name,
marker.data
);
const schemaName = marker.data ? (marker.data.type ?? null) : null;
return schemaName !== null && markerTypes.has(schemaName);
});
}
Expand Down
30 changes: 4 additions & 26 deletions src/profile-logic/marker-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,34 +82,16 @@ export const markerSchemaFrontEndOnly: MarkerSchema[] = [
},
];

export function getMarkerSchemaName(
markerSchemaByName: MarkerSchemaByName,
markerName: string,
markerData: MarkerPayload | null
): string | null {
if (!markerData || !markerData.type) {
// No schema.
return null;
}

return markerData.type;
}

/**
* This function takes the intended marker schema for a marker field, and applies
* the appropriate formatting function.
*/
export function getSchemaFromMarker(
markerSchemaByName: MarkerSchemaByName,
markerName: string,
markerData: MarkerPayload | null
): MarkerSchema | null {
const schemaName = getMarkerSchemaName(
markerSchemaByName,
markerName,
markerData
);
return schemaName !== null ? (markerSchemaByName[schemaName] ?? null) : null;
const schemaName = markerData ? markerData.type : null;
return schemaName ? (markerSchemaByName[schemaName] ?? null) : null;
}

/**
Expand Down Expand Up @@ -363,12 +345,8 @@ export function getLabelGetter(
// No label exists, it will have to be generated for the first time.
if (label === undefined) {
const marker = getMarker(markerIndex);
const schemaName = getMarkerSchemaName(
markerSchemaByName,
marker.name,
marker.data
);
const applyLabel = schemaName !== null ? labelFns.get(schemaName) : null;
const schemaName = marker.data ? marker.data.type : null;
const applyLabel = schemaName ? labelFns.get(schemaName) : null;

label = applyLabel
? // A label function is available, apply it.
Expand Down
3 changes: 0 additions & 3 deletions src/profile-logic/sanitize.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,8 @@ function sanitizeThreadPII(

if (currentMarker && PIIToBeRemoved.shouldRemoveUrls) {
// Use the schema to find some properties that need to be sanitized.
const markerNameIndex = markerTable.name[i];
const markerName = thread.stringTable.getString(markerNameIndex);
const markerSchema = getSchemaFromMarker(
markerSchemaByName,
markerName,
currentMarker
);
if (markerSchema) {
Expand Down
11 changes: 2 additions & 9 deletions src/profile-logic/tracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ import type {
Counter,
Tid,
TrackReference,
MarkerSchemaByName,
TabID,
} from 'firefox-profiler/types';

import { defaultThreadOrder, getFriendlyThreadName } from './profile-data';
import { intersectSets, subtractSets } from '../utils/set';
import { splitSearchString, stringsToRegExp } from '../utils/string';
import { ensureExists, assertExhaustiveCheck } from '../utils/flow';
import { getMarkerSchemaName } from './marker-schema';

export type TracksWithOrder = {|
+globalTracks: GlobalTrack[],
Expand Down Expand Up @@ -258,8 +256,7 @@ export function initializeLocalTrackOrderByPid(
*/
export function computeLocalTracksByPid(
profile: Profile,
availableGlobalTracks: GlobalTrack[],
markerSchemaByName: MarkerSchemaByName
availableGlobalTracks: GlobalTrack[]
): Map<Pid, LocalTrack[]> {
const localTracksByPid = new Map();

Expand Down Expand Up @@ -323,11 +320,7 @@ export function computeLocalTracksByPid(
for (let i = 0; i < markers.length; ++i) {
const markerNameIndex = markers.name[i];
const markerData = markers.data[i];
const markerSchemaName = getMarkerSchemaName(
markerSchemaByName,
thread.stringTable.getString(markerNameIndex),
markerData
);
const markerSchemaName = markerData ? markerData.type : null;
if (markerData && markerSchemaName) {
const mapEntry = markerTracksBySchemaName.get(markerSchemaName);
if (mapEntry && mapEntry.keys.every((k) => k in markerData)) {
Expand Down
11 changes: 2 additions & 9 deletions src/selectors/per-thread/markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import * as MarkerData from '../../profile-logic/marker-data';
import * as MarkerTimingLogic from '../../profile-logic/marker-timing';
import * as ProfileSelectors from '../profile';
import { getRightClickedMarkerInfo } from '../right-clicked-marker';
import {
getLabelGetter,
getMarkerSchemaName,
} from '../../profile-logic/marker-schema';
import { getLabelGetter } from '../../profile-logic/marker-schema';
import { getInclusiveSampleIndexRangeForSelection } from '../../profile-logic/profile-data';

import type { BasicThreadSelectorsPerThread } from './thread';
Expand Down Expand Up @@ -682,11 +679,7 @@ export function getMarkerSelectorsPerThread(
if (
data &&
marker.name === name &&
getMarkerSchemaName(
ProfileSelectors.getMarkerSchemaByName,
marker.name,
data
) === schemaName &&
data.type === schemaName &&
keys.every((key) => key in data)
) {
markerIndexes.push(index);
Expand Down

0 comments on commit 02732bf

Please sign in to comment.