-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fix fill_tiled segfault #521
Conversation
Reviewer's Guide by SourceryThe PR fixes a segfault in the fill_tiled function by introducing a temporary layout and cell to handle fill operations. Instead of directly modifying the target cell during the filling process, the changes are first applied to a temporary cell and then transferred to the target cell in a controlled manner. Sequence diagram for fill_tiled function changessequenceDiagram
participant FillOperator
participant temp_ly as Temporary Layout
participant temp_tc as Temporary Cell
participant top_cell as Top Cell
participant fill_cell as Fill Cell
fill_tiled->>FillOperator: Create FillOperator instance
FillOperator->>temp_ly: Start changes
FillOperator->>temp_tc: fill_region_multi or fill_region
FillOperator->>temp_ly: End changes
FillOperator->>temp_tc: Iterate each_inst
temp_tc->>top_cell: Insert cell_inst_array
fill_tiled->>FillOperator: insert_fill()
FillOperator->>top_cell: Insert fill cell into regions
Class diagram for FillOperator changesclassDiagram
class FillOperator {
+list<kdb.Cell> filled_cells
+kdb.Layout temp_ly
+kdb.Cell temp_tc
+kdb.Cell temp_fc
+int temp_fc_ind
+void insert_fill()
}
FillOperator : fill_region_multi(region, fill_cell_index, fc_bbox, row_step, column_step, fill_margin, glue_box)
FillOperator : fill_region(region, fill_cell_index, fc_bbox, row_step, column_step, fill_margin, glue_box)
note for FillOperator "New attributes and method added to handle temporary layout and cell operations"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.
cell_inst_array = inst.cell_inst | ||
cell_inst_array.cell_index = self.fill_cell_index | ||
self.top_cell.insert(cell_inst_array) | ||
|
||
|
||
def fill_tiled( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): We've found these issues:
- Split conditional into multiple branches [×2] (
split-or-ifs
) - Merge duplicate blocks in conditional [×2] (
merge-duplicate-blocks
) - Replace if statement with if expression (
assign-if-exp
) - Remove redundant conditional (
remove-redundant-if
) - Replace mutable default arguments with None (
default-mutable-arg
) - Low code quality found in fill_tiled - 6% (
low-code-quality
)
Explanation
The quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.
How can you solve this?
It might be worth refactoring this function to make it shorter and more readable.
- Reduce the function length by extracting pieces of functionality out into
their own functions. This is the most important thing you can do - ideally a
function should be less than 10 lines. - Reduce nesting, perhaps by introducing guard clauses to return early.
- Ensure that variables are tightly scoped, so that code using related concepts
sits together within the function rather than being scattered.
fix KLayout/klayout#1929
Summary by Sourcery
Bug Fixes: