Skip to content

Conversation

@RivaKing
Copy link

@RivaKing RivaKing commented May 14, 2025


Important

Improves GWF-to-SCs translation with new command-line options and enhanced SCs file output handling in sc_builder_runner.cpp and sc_scs_writer.cpp.

  • Behavior:
    • Added --gwf-to-scs and --gwf-output options in sc_builder_runner.cpp for translating GWF files to SCs.
    • Enhanced SCs file output in SCsWriter::Write() in sc_scs_writer.cpp to handle nodes, arcs, and contours more effectively.
  • Functions:
    • PrintHelpMessage() in sc_builder_runner.cpp updated with new options for GWF-to-SCs translation.
    • SCsWriter::Write() refactored to improve node and arc processing, including handling of SCgLinks and image content.
    • Added SCsWriter::CollectNodes() to recursively gather nodes, including those in contours.
  • Misc:
    • Included sc_scg_to_scs_types_converter.hpp in sc_scs_writer.cpp for type conversion.
    • Updated SCsWriter::SCgIdentifierCorrector methods for identifier correction.

This description was created by Ellipsis for e7e2424. You can customize this summary. It will automatically update as commits are pushed.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed everything up to e7e2424 in 2 minutes and 38 seconds. Click for details.
  • Reviewed 709 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. sc-tools/sc-builder/src/sc_scs_writer.cpp:242
  • Draft comment:
    The nested loop for attribute arc lookup could be optimized for performance if the element set is large.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50% While the loop could potentially be optimized by using a different data structure, there's no evidence in the code that this is a performance bottleneck. The code already has an early break and the operation only happens for complex arcs. Without profiling data or clear evidence of performance issues, this seems like premature optimization. The comment could be valid if this code processes very large graphs where performance is critical. The current implementation is O(n) for each complex arc. However, the code appears to be part of a file writer/serializer which is likely not in a performance-critical path. The current implementation prioritizes readability and maintainability. The comment should be deleted as it suggests optimization without clear evidence of need, making it speculative rather than actionable.

Workflow ID: wflow_AzBo1HFyETNEoagk

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

std::ofstream output(outputFile, std::ios::binary);
if (!output.is_open())
{
std::cout << "Error: Cannot open output file `" << outputFile << "`.\n";
Copy link

Choose a reason for hiding this comment

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

Consider using std::cerr for error messages instead of std::cout.

Suggested change
std::cout << "Error: Cannot open output file `" << outputFile << "`.\n";
std::cerr << "Error: Cannot open output file `" << outputFile << "`.\n";

auto link = std::dynamic_pointer_cast<SCgLink>(node);
if (link && link->GetContentType() != NO_CONTENT)
{
std::string contentTypeStr = link->GetContentType();
Copy link

Choose a reason for hiding this comment

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

Validate contentTypeStr before converting with std::stoi to avoid exceptions from malformed data.

}
else if (contentType == 4) // IMAGE
{
std::string fileName = link->GetFileName();
Copy link

Choose a reason for hiding this comment

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

Sanitize fileName to prevent potential directory traversal issues when constructing file paths.

Suggested change
std::string fileName = link->GetFileName();
std::string fileName = std::filesystem::path(link->GetFileName()).filename().string();


if (!attrSourceId.empty())
{
std::string connectorSymbol;
Copy link

Choose a reason for hiding this comment

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

Consider refactoring the connector printing logic into a helper function to reduce code duplication.

}
}

void SCsWriter::Write(
Copy link

Choose a reason for hiding this comment

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

Consider splitting the lengthy Write() function into smaller helper functions to improve readability and maintainability.

@NikitaZotov NikitaZotov marked this pull request as draft July 14, 2025 14:59
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