Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make requireFiles do less work for larger applications #470

Merged

Conversation

misterbyrne
Copy link
Contributor

We have a very large Ember application with loads of modules, so the requireFiles function takes a long time.

This is because the fileSeen array is very long, but only a very small subset of these match the filePattern regex.
The filePattern regex is very simple, but the excludeRegex is more complex. So if we evaluate the simple one first, we'll only have to evaluate the more complex one a much smaller number of times.

I also took the opportunity to simplify the excludeRegex since it's the file extension that we really care about - at the end of the path.

Time spent in requireFiles for one test module of our app before the change was 2605ms, time spent after the change was 70ms.

@patocallaghan patocallaghan merged commit 9fbdc8b into adopted-ember-addons:master Oct 21, 2022
@patocallaghan
Copy link
Collaborator

Thanks @misterbyrne 🙌

@patocallaghan
Copy link
Collaborator

Released in 3.9.11

@misterbyrne misterbyrne deleted the ab/faster-require branch October 24, 2022 08:22
mandyheg pushed a commit to intercom/ember-data-factory-guy that referenced this pull request Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants