realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

OrderedCollection no longer requires a Results

Open RedBeard0531 opened this issue 2 years ago • 1 comments

Previously it always held a Results object, even for the List and Set subclasses. That was expensive to construct, and possibly changed the runtime complexity. Now it will directly work with whatever native object it's subclass represents. This required a small change to the core spec file to give Results and Collections a compatible API.

Before

Node:
    reading property of type 'bool?[]'
      ✓ reads bool?[] (129,694 ops/sec, ±48.46%)
    reading property of type 'bool?<>'
      ✓ reads bool?<> (178,647 ops/sec, ±31.71%)
Hermes:
    reading property of type 'bool?[]'
      ✓ reads bool?[] (43,417 ops/sec, ±11.36%)
    reading property of type 'bool?<>'
      ✓ reads bool?<> (48,925 ops/sec, ±12.1%)

After

Node:
    reading property of type 'bool?[]'
      ✓ reads bool?[] (211,569 ops/sec, ±34.5%)
    reading property of type 'bool?<>'
      ✓ reads bool?<> (237,292 ops/sec, ±20.4%)
Hermes:
    reading property of type 'bool?[]'
      ✓ reads bool?[] (56,075 ops/sec, ±13.68%)
    reading property of type 'bool?<>'
      ✓ reads bool?<> (59,356 ops/sec, ±11.46%)

What, How & Why?

☑️ ToDos

  • [ ] 📝 Changelog entry
  • [ ] 📝 Compatibility label is updated or copied from previous entry
  • [ ] 📝 Update COMPATIBILITY.md
  • [ ] 🚦 Tests
  • [ ] 🔀 Executed flexible sync tests locally if modifying flexible sync
  • [ ] 📦 Updated internal package version in consuming package.jsons (if updating internal packages)
  • [ ] 📱 Check the React Native/other sample apps work if necessary
  • [ ] 📝 Public documentation PR created or is not necessary
  • [ ] 💥 Breaking label has been applied or is not necessary

If this PR adds or changes public API's:

  • [ ] typescript definitions file is updated
  • [ ] jsdoc files updated

RedBeard0531 avatar Jun 02 '23 15:06 RedBeard0531

Unfortunately some of the test failures are due to https://github.com/realm/realm-core/issues/6695. We may need to convert to Results for some of these methods for now, or implement them in JS.

RedBeard0531 avatar Jun 06 '23 10:06 RedBeard0531