Skip to content

Conversation

@admirsaheta
Copy link

What changes are you making?

We are optimizing the encodeToJSON function and the UIColor extension to improve performance and maintainability. Specifically, we are:

  1. Reusing JSONEncoder : By creating a single instance of JSONEncoder , we avoid the overhead of creating a new encoder each time the function is called, which can lead to performance improvements.
  2. Caching UIColor Instances : The UIColor extension now caches color instances to avoid redundant parsing of hex strings and creation of new UIColor objects, improving performance when the same colors are used repeatedly.

How to test

Performance Testing : Measure the performance of the functions before and after the changes to verify improvements.


PR Checklist

Important


Checklist for releasing a new version

Tip

See the Contributing documentation for instructions on how to publish a new version of the library.

@admirsaheta admirsaheta requested a review from a team as a code owner April 18, 2025 14:46
@markmur markmur requested a review from Copilot April 22, 2025 14:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves performance and maintainability by optimizing JSON encoding and caching UIColor instances.

  • Reuses a JSONEncoder instance to reduce overhead
  • Caches UIColor instances by hex string to avoid redundant computations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.swift Replaces per-call JSONEncoder instantiation with a reusable instance and adds caching logic for UIColor extensions.
CHANGELOG.md Updates changelog entries reflecting the performance improvements introduced.

@markmur
Copy link
Contributor

markmur commented Apr 22, 2025

Thanks for the contribution but the performance gain here is negligible.

@markmur markmur closed this Apr 22, 2025
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