Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions packages/skia/cpp/api/recorder/Drawings.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ class TextCmd : public Command {
}
};

// Add to Drawings.h after existing command structures
struct BoxShadowCmdProps {
float dx = 0;
float dy = 0;
Expand Down Expand Up @@ -386,16 +385,17 @@ class BoxCmd : public Command {
for (size_t i = 0; i < shadowCount; i++) {
auto shadowObj =
shadowsArray.getValueAtIndex(runtime, i).asObject(runtime);
BoxShadowCmdProps shadow;

convertProperty(runtime, shadowObj, "dx", shadow.dx, variables);
convertProperty(runtime, shadowObj, "dy", shadow.dy, variables);
convertProperty(runtime, shadowObj, "spread", shadow.spread, variables);
convertProperty(runtime, shadowObj, "blur", shadow.blur, variables);
convertProperty(runtime, shadowObj, "color", shadow.color, variables);
convertProperty(runtime, shadowObj, "inner", shadow.inner, variables);

shadows.push_back(shadow);

// Create shadow directly in vector to avoid copy
shadows.emplace_back();
BoxShadowCmdProps &shadow = shadows.back();
Comment on lines +389 to +391
Copy link
Preview

Copilot AI Sep 12, 2025

Choose a reason for hiding this comment

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

The comment mentions avoiding copy, but this approach still creates a default-constructed object then modifies it. Consider using emplace_back with direct initialization of the struct members to truly avoid intermediate object creation.

Copilot uses AI. Check for mistakes.


convertProperty(runtime, shadowObj, "dx", shadow.dx, variables);
convertProperty(runtime, shadowObj, "dy", shadow.dy, variables);
convertProperty(runtime, shadowObj, "spread", shadow.spread, variables);
convertProperty(runtime, shadowObj, "blur", shadow.blur, variables);
convertProperty(runtime, shadowObj, "color", shadow.color, variables);
convertProperty(runtime, shadowObj, "inner", shadow.inner, variables);
}
}

Expand Down
Loading