Skip to content

Eliminate duplicate condition check in buildSnapshot#18

Merged
byemaxx merged 3 commits intostagingfrom
copilot/sub-pr-16-again
Jan 7, 2026
Merged

Eliminate duplicate condition check in buildSnapshot#18
byemaxx merged 3 commits intostagingfrom
copilot/sub-pr-16-again

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 7, 2026

The shrinkToContent condition was evaluated twice in the same function—once for the baseWidth calculation and again when defining the variable itself. This creates duplication and increases risk of inconsistency.

Changes:

  • Extract shrinkToContent variable definition to occur once before baseWidth calculation
  • Reuse the extracted variable in the conditional logic
// Before
let baseWidth;
if (opts && opts.widthStrategy === 'shrink-to-content') {
  baseWidth = Math.max(el.scrollWidth || 0, el.offsetWidth || 0, 1);
  // ...
}
const clone = el.cloneNode(true);
const shrinkToContent = !!(opts && opts.widthStrategy === 'shrink-to-content');

// After
const shrinkToContent = !!(opts && opts.widthStrategy === 'shrink-to-content');
let baseWidth;
if (shrinkToContent) {
  baseWidth = Math.max(el.scrollWidth || 0, el.offsetWidth || 0, 1);
  // ...
}
const clone = el.cloneNode(true);

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: byemaxx <44231502+byemaxx@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on matrix layout and export adjustments Eliminate duplicate condition check in buildSnapshot Jan 7, 2026
Copilot AI requested a review from byemaxx January 7, 2026 00:18
@byemaxx byemaxx marked this pull request as ready for review January 7, 2026 00:28
@byemaxx byemaxx merged commit f2bafaf into staging Jan 7, 2026
@byemaxx byemaxx deleted the copilot/sub-pr-16-again branch January 7, 2026 00:30
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