Skip to content

minor code changes for better readability #391

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

manthan127
Copy link

refactor: simplify VNDetectRectanglesRequest & AVCaptureVideoOrientation initialization

What

  • Simplified rectangle detection request creation by removing an unnecessary closure:

    let rectangleDetectionRequest = VNDetectRectanglesRequest(completionHandler: { request, error in
        ...
    })

    instead of:

    let rectangleDetectionRequest: VNDetectRectanglesRequest = {
        let rectDetectRequest = VNDetectRectanglesRequest(completionHandler: { request, error in
            ...
        })
        return rectDetectRequest
    }()
  • Simplified enum initialization in AVCaptureVideoOrientation by assigning enum cases directly:

    self = .portrait

    instead of:

    self.init(rawValue: AVCaptureVideoOrientation.portrait.rawValue)

Why

  • These changes reduce verbosity and make the code easier to read and maintain.
  • Behavior remains identical; this is purely a readability and style improvement.

How

  • Replaced closure-based initialization with direct assignment.
  • Replaced .init(rawValue:) usage with direct enum case assignment.

Testing

  • Verified functionality manually (rectangle detection and orientation mapping).
  • No change in logic, so no additional tests required.

Risks

  • Minimal; only refactoring for clarity with no behavior changes.

Feedback welcome on whether this style aligns with project conventions or if further adjustments are needed.

@manthan127 manthan127 requested a review from a team as a code owner July 25, 2025 16:44
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