Skip to content

♻️ peformance-impl: simplify tick()#26567

Merged
samouri merged 3 commits intoampproject:masterfrom
samouri:clarify-tick
Feb 4, 2020
Merged

♻️ peformance-impl: simplify tick()#26567
samouri merged 3 commits intoampproject:masterfrom
samouri:clarify-tick

Conversation

@samouri
Copy link
Copy Markdown
Member

@samouri samouri commented Jan 30, 2020

  • places all of tick()'s branched logic in a single place near the top, instead of being spread throughout.
  • only sends value or delta, instead of both.

@samouri samouri requested a review from jridgewell January 30, 2020 20:21
@samouri samouri self-assigned this Jan 30, 2020
}
// Mark the event on the browser timeline, but only if there was
// no delta (in which case it would not make sense).
if (arguments.length == 1) {
Copy link
Copy Markdown
Member Author

@samouri samouri Jan 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why check arguments.length == 1 as opposed to for a null/undefined opt_delta?

// variables.
const storedVal = Math.round(
opt_delta != null ? Math.max(opt_delta, 0) : value - this.initTime_
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually find this less readable. I think there's a ToTT for it somewhere but I also found this: https://refactoring.com/catalog/reduceScopeOfVariable.html

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You prefer the opt_delta condition repeated 3 times?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking of this line, I have a question. Why in the absolute case (relative to epoch) do we set storedVal to the delta?

Copy link
Copy Markdown
Member Author

@samouri samouri Feb 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

answer: its used in the url-rewriter, and non-viewer use cases care more about relative than absolute times (this is still fishy, why do we ever send absolute times).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants