Skip to content

Commit

Permalink
Reverted perf regression
Browse files Browse the repository at this point in the history
  • Loading branch information
rubennorte committed Nov 7, 2018
1 parent 90f2d71 commit 8f099fd
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/jest-haste-map/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import type {Mapper} from './types';
import type {Path} from 'types/Config';
import type {
HasteMap as HasteMapObject,
FileData as HasteMapFileData,
InternalHasteMap,
ModuleMetaData,
ModuleMapData,
Expand Down Expand Up @@ -361,7 +360,7 @@ class HasteMap extends EventEmitter {
* 2. crawl the file system.
*/
_buildFileMap(): Promise<{
deprecatedFiles: HasteMapFileData,
deprecatedFiles: Array<{moduleName: string, path: string}>,
hasteMap: InternalHasteMap,
}> {
const read = this._options.resetCache ? this._createEmptyMap : this.read;
Expand All @@ -370,14 +369,15 @@ class HasteMap extends EventEmitter {
.then(() => read.call(this))
.catch(() => this._createEmptyMap())
.then(cachedHasteMap => {
const cachedFiles = new Map(cachedHasteMap.files);
const cachedFiles = [];
for (const [relativeFilePath, fileMetadata] of cachedHasteMap.files) {
const moduleName = fileMetadata[H.ID];
cachedFiles.push({moduleName, path: relativeFilePath});
}
return this._crawl(cachedHasteMap).then(hasteMap => {
const deprecatedFiles = new Map();
for (const [fileName, fileData] of cachedFiles) {
if (!hasteMap.files.has(fileName)) {
deprecatedFiles.set(fileName, fileData);
}
}
const deprecatedFiles = cachedFiles.filter(
file => !hasteMap.files.has(file.path),
);
return {deprecatedFiles, hasteMap};
});
});
Expand Down Expand Up @@ -579,17 +579,17 @@ class HasteMap extends EventEmitter {
}

_buildHasteMap(data: {
deprecatedFiles: HasteMapFileData,
deprecatedFiles: Array<{moduleName: string, path: string}>,
hasteMap: InternalHasteMap,
}): Promise<InternalHasteMap> {
const {deprecatedFiles, hasteMap} = data;
const map = new Map();
const mocks = new Map();
const promises = [];

for (const [filePath, fileData] of deprecatedFiles) {
const moduleName = fileData[H.ID];
this._recoverDuplicates(hasteMap, filePath, moduleName);
for (let i = 0; i < deprecatedFiles.length; ++i) {
const file = deprecatedFiles[i];
this._recoverDuplicates(hasteMap, file.path, file.moduleName);
}

for (const relativeFilePath of hasteMap.files.keys()) {
Expand Down

0 comments on commit 8f099fd

Please sign in to comment.