diff --git a/.changeset/tricky-keys-kneel.md b/.changeset/tricky-keys-kneel.md new file mode 100644 index 000000000..e038f1763 --- /dev/null +++ b/.changeset/tricky-keys-kneel.md @@ -0,0 +1,5 @@ +--- +"@callstack/repack": minor +--- + +Optimize 'checkIfCacheDataOutdated' to do as few comparisons as possible diff --git a/packages/repack/src/modules/ScriptManager/Script.ts b/packages/repack/src/modules/ScriptManager/Script.ts index d92f83f93..95cf06440 100644 --- a/packages/repack/src/modules/ScriptManager/Script.ts +++ b/packages/repack/src/modules/ScriptManager/Script.ts @@ -213,15 +213,13 @@ export class Script { 'method' | 'url' | 'query' | 'headers' | 'body' > ) { - const diffs = [ - cachedData.method !== this.locator.method, - cachedData.url !== this.locator.url, - cachedData.query !== this.locator.query, - !shallowEqual(cachedData.headers, this.locator.headers), - cachedData.body !== this.locator.body, - ]; - - return diffs.some((diff) => diff); + return ( + cachedData.method !== this.locator.method || + cachedData.url !== this.locator.url || + cachedData.query !== this.locator.query || + !shallowEqual(cachedData.headers, this.locator.headers) || + cachedData.body !== this.locator.body + ); } /**