Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: small code simplificiations #9208

Merged
merged 1 commit into from
Jan 22, 2024
Merged

refactor: small code simplificiations #9208

merged 1 commit into from
Jan 22, 2024

Conversation

domoritz
Copy link
Member

No description provided.

@domoritz domoritz requested a review from a team as a code owner December 15, 2023 19:11
@domoritz domoritz enabled auto-merge (squash) December 15, 2023 19:14
@@ -76,7 +76,7 @@ const scaleBindings: SelectionCompiler<'interval'> = {
// Nested signals need only push to top-level signals with multiview displays.
if (model.parent && !isTopLevelLayer(model)) {
for (const proj of selCmpt.scales) {
const signal: any = signals.filter(s => s.name === proj.signals.data)[0];
const signal: any = signals.find(s => s.name === proj.signals.data);
Copy link
Member

Choose a reason for hiding this comment

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

Is this guaranteed to exist?

Copy link
Member Author

Choose a reason for hiding this comment

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

Find returns undefined if there is no such item. The previous code would crash so I think the new one is strictly better, no?

Copy link
Member

Choose a reason for hiding this comment

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

Isn't the following line signal.push = ...? If find returns undefined what would we do? Otherwise why will it always be defined?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure but the previous behavior was to get an element from an empty array which also returns undefined so this should be an equivalent change.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough. I was just hoping we'd be able to also add some sort of comment to increase confidence in local reasoning.

@domoritz domoritz merged commit 39d9ee3 into main Jan 22, 2024
9 checks passed
@domoritz domoritz deleted the dom/refactor branch January 22, 2024 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants