🐎 Join paths manually

path.join calls path.normalize and with the number of paths
being pushed through the cache it is faster to require them
manually since they are already normalized
This commit is contained in:
Kevin Sawicki
2014-10-09 15:24:04 -07:00
parent a6866656b7
commit db627f5cde

View File

@@ -222,26 +222,29 @@ exports.register = ({resourcePath, devMode}={}) ->
return
exports.add = (directoryPath, metadata) ->
# path.join isn't used in this function for speed since path.join calls
# path.normalize and all the paths are already normalized here.
unless metadata?
try
metadata = require(path.join(directoryPath, 'package.json'))
metadata = require("#{directoryPath}#{path.sep}package.json")
catch error
return
cacheToAdd = metadata?._atomModuleCache
for dependency in cacheToAdd?.dependencies ? []
cache.dependencies[dependency.name] ?= {}
cache.dependencies[dependency.name][dependency.version] ?= path.join(directoryPath, dependency.path)
cache.dependencies[dependency.name][dependency.version] ?= "#{directoryPath}#{path.sep}#{dependency.path}"
for entry in cacheToAdd?.folders ? []
for folderPath in entry.paths
cache.folders[path.join(directoryPath, folderPath)] = entry.dependencies
cache.folders["#{directoryPath}#{path.sep}#{folderPath}"] = entry.dependencies
if directoryPath is cache.resourcePath
for extension, paths of cacheToAdd?.extensions
cache.extensions[extension] ?= new Set()
for filePath in paths
cache.extensions[extension].add(path.join(directoryPath, filePath))
cache.extensions[extension].add("#{directoryPath}#{path.sep}#{filePath}")
return