Skip to content

Conversation

@czlitony
Copy link

Problem

Opening the sample file becomes significantly slow when the Full Report section is large.

Root Cause

The regular expression used to parse the Binary Images section is greedy, causing excessive backtracking and poor performance when processing large Full Report blocks.

Fix

Replaced the greedy regex with a non-greedy variant to improve the efficiency of parsing the Binary Images section. This change reduces unnecessary processing and improves file loading time, especially for large reports.

let loadAddress: String

private static let binaryImagesSectionRegex = #"Binary Images:.*"#
private static let binaryImagesSectionRegex = #"Binary Images:.*?(?=\n\s*\n|\Z)"#
Copy link
Author

Choose a reason for hiding this comment

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

The regex modification changes #"Binary Images:.*"# to #"Binary Images:.*?(?=\n\s*\n|\Z)"# to improve efficiency:

  • .*? - Non-greedy match of any characters (instead of greedy .*)
  • (?=\n\s*\n|\Z) - Positive lookahead that stops matching when encountering:
    • \n\s*\n - An empty line (newline + optional whitespace + newline)
    • |\Z - Or end of document

This ensures the scan operation only captures content from "Binary Images:" until the first empty line or document end, preventing it from scanning the entire document and improving performance when processing large crash

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.

1 participant