expo icon indicating copy to clipboard operation
expo copied to clipboard

[iOS][core] Use singletons for string and data dynamic types

Open tsapeta opened this issue 1 year ago • 1 comments

Why

We can use shared instance for DynamicStringType and DynamicDataType as they are not generic. It reduces a number of dynamic types we need to create for arguments on startup and for the returned values during a function call. Swift doesn't support static stored properties in generic types, so doing this in other dynamic types requires more work.

How

Added shared static property to DynamicStringType and DynamicDataType and confirmed that only one object is created for the type (instead of more than 30 for strings).

Test Plan

Ensured it works fine in my benchmarks and also tested it against some test-suite tests

tsapeta avatar Aug 28 '24 11:08 tsapeta

The Pull Request introduced fingerprint changes against the base commit: 06ebec2239aade89370303ef40d08656d03194a0

Fingerprint diff
[
  {
    "op": "changed",
    "source": {
      "type": "dir",
      "filePath": "../../packages/expo-modules-core",
      "reasons": [
        "expoAutolinkingIos",
        "expoAutolinkingAndroid"
      ],
      "hash": "bf9a44cda7f4a4b0f1ed3f0aa67af72d93894342"
    }
  }
]

Generated by PR labeler 🤖

expo-bot avatar Aug 28 '24 11:08 expo-bot