Skip to content

Commit

Permalink
remove RelayProfiler from RelayModernStore.prototype.lookup and Relay…
Browse files Browse the repository at this point in the history
…Profiler.instrumentMethods

Reviewed By: josephsavona

Differential Revision: D27566450

fbshipit-source-id: 732058094b5924f4be2c0020288894b034112b6e
  • Loading branch information
kassens authored and facebook-github-bot committed Apr 6, 2021
1 parent 3b8ee7a commit f486653
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 296 deletions.
5 changes: 0 additions & 5 deletions packages/relay-runtime/store/RelayModernStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const DataChecker = require('./DataChecker');
const RelayFeatureFlags = require('../util/RelayFeatureFlags');
const RelayModernRecord = require('./RelayModernRecord');
const RelayOptimisticRecordSource = require('./RelayOptimisticRecordSource');
const RelayProfiler = require('../util/RelayProfiler');
const RelayReader = require('./RelayReader');
const RelayReferenceMarker = require('./RelayReferenceMarker');
const RelayStoreReactFlightUtils = require('./RelayStoreReactFlightUtils');
Expand Down Expand Up @@ -770,8 +769,4 @@ function getAvailabilityStatus(
return {status: 'available', fetchTime: operationFetchTime ?? null};
}

RelayProfiler.instrumentMethods(RelayModernStore.prototype, {
lookup: 'RelayModernStore.prototype.lookup',
});

module.exports = RelayModernStore;
28 changes: 0 additions & 28 deletions packages/relay-runtime/util/RelayProfiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,6 @@ const shouldInstrument = name => {
* if `__DEV__` is true. This should be used for very hot functions.
*/
const RelayProfiler = {
/**
* Instruments methods on a class or object. This re-assigns the method in
* order to preserve function names in stack traces (which are detected by
* modern debuggers via heuristics). Example usage:
*
* const RelayStore = { primeCache: function() {...} };
* RelayProfiler.instrumentMethods(RelayStore, {
* primeCache: 'RelayStore.primeCache'
* });
*
* RelayStore.primeCache.attachHandler(...);
*
* As a result, the methods will be replaced by wrappers that provide the
* `attachHandler` and `detachHandler` methods.
*/
instrumentMethods(
object: Function | Object,
names: {[key: string]: string, ...},
): void {
for (const key in names) {
if (names.hasOwnProperty(key)) {
if (typeof object[key] === 'function') {
object[key] = RelayProfiler.instrument(names[key], object[key]);
}
}
}
},

/**
* Wraps the supplied function with one that provides the `attachHandler` and
* `detachHandler` methods. Example usage:
Expand Down
5 changes: 0 additions & 5 deletions packages/relay-runtime/util/__mocks__/RelayProfiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
'use strict';

const RelayProfiler = {
instrumentMethods: jest.fn((object, names) => {
for (const [key, name] of Object.entries(names)) {
object[key] = RelayProfiler.instrument(name, object[key]);
}
}),
instrument: jest.fn((name, handler) => {
handler.attachHandler = () => {};
handler.detachHandler = () => {};
Expand Down
Loading

0 comments on commit f486653

Please sign in to comment.