Skip to content

Commit 15652f8

Browse files
committed
memoize in place
1 parent c1b23d2 commit 15652f8

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

packages/platform-ios/src/config/findProject.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import glob from 'glob';
1212
import path from 'path';
13-
import {memoize} from 'lodash';
1413

1514
/**
1615
* Glob pattern to look for xcodeproj
@@ -38,10 +37,9 @@ const GLOB_EXCLUDE_PATTERN = ['**/@(Pods|node_modules)/**'];
3837
*
3938
* Returns first match if files are found or null
4039
*
41-
* Note: `./ios/*.xcodeproj` are returned regardless of the name.
42-
* Note2: Globbing is expensive and often repeated on the same folder, hence memoizing
40+
* Note: `./ios/*.xcodeproj` are returned regardless of the name
4341
*/
44-
export default memoize(function findProject(folder: string): string | null {
42+
export default function findProject(folder: string): string | null {
4543
const projects = glob
4644
.sync(GLOB_PATTERN, {
4745
cwd: folder,
@@ -58,4 +56,4 @@ export default memoize(function findProject(folder: string): string | null {
5856
}
5957

6058
return projects[0];
61-
});
59+
}

packages/platform-ios/src/config/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
*/
1010

1111
import path from 'path';
12+
import {memoize} from 'lodash';
1213
import findProject from './findProject';
1314
import findPodfilePath from './findPodfilePath';
1415
import findPodspec from './findPodspec';
1516
import type {UserConfigT} from 'types';
1617

18+
const memoizedFindProject = memoize(findProject);
19+
1720
/**
1821
* For libraries specified without an extension, add '.tbd' for those that
1922
* start with 'lib' and '.framework' to the rest.
@@ -37,7 +40,7 @@ export function projectConfig(
3740
if (!userConfig) {
3841
return;
3942
}
40-
const project = userConfig.project || findProject(folder);
43+
const project = userConfig.project || memoizedFindProject(folder);
4144

4245
/**
4346
* No iOS config found here

0 commit comments

Comments
 (0)