mfncooper/mockery#46 caused some large performance issues as it is unnecessarily checking the cache every time a module is loaded. The check itself does not take long, but the sheer number of times it's called (uselessly) when mocking even a single module can be problematic. When mocking a module that itself has many other imports, this check can be called 100+ times, when it only needed to be called once.
I've moved it so that the cache is only repopulated with native modules when it's reset. This should hopefully allow keeping the fix to mfncooper/mockery#45 while keeping the performance impact to a minimum.
mfncooper/mockery#46 caused some large performance issues as it is unnecessarily checking the cache every time a module is loaded. The check itself does not take long, but the sheer number of times it's called (uselessly) when mocking even a single module can be problematic. When mocking a module that itself has many other imports, this check can be called 100+ times, when it only needed to be called once.
I've moved it so that the cache is only repopulated with native modules when it's reset. This should hopefully allow keeping the fix to mfncooper/mockery#45 while keeping the performance impact to a minimum.