Skip to content

Commit

Permalink
Add a comment explaining the copies of some variables in the sample g…
Browse files Browse the repository at this point in the history
…raph
  • Loading branch information
canova committed Jan 15, 2025
1 parent 34909ce commit ede1005
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/shared/thread/SampleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ export class ThreadSampleGraphImpl extends PureComponent<Props, State> {
const x = event.nativeEvent.offsetX;
const time = rangeStart + (x / r.width) * (rangeEnd - rangeStart);

// These values are copied from the `drawCanvas` method to compute the
// `drawnSampleWidth` instead of extracting into a new function. Extracting
// into a new function is not really idea for performance reasons since we
// need these values for other values in `drawCanvas`.
const rangeLength = rangeEnd - rangeStart;
const xPixelsPerMs = r.width / rangeLength;
const trueIntervalPixelWidth = interval * xPixelsPerMs;
Expand Down

0 comments on commit ede1005

Please sign in to comment.