Make spliting paths faster.

This commit is contained in:
Cheng Zhao 2014-09-25 22:18:40 +08:00
parent c49a44f944
commit 8acf96d268

View file

@ -18,14 +18,11 @@ process.on 'exit', ->
# Separate asar package's path from full path. # Separate asar package's path from full path.
splitPath = (p) -> splitPath = (p) ->
return [false, p] unless typeof p is 'string' return [false] if typeof p isnt 'string'
components = p.split path.sep return [true, p, ''] if p.substr(-5) is '.asar'
for c, i in components by -1 index = p.lastIndexOf ".asar#{path.sep}"
if path.extname(c) is '.asar' return [false] if index is -1
asarPath = components.slice(0, i + 1).join path.sep [true, p.substr(0, index + 5), p.substr(index + 6)]
filePath = components.slice(i + 1).join path.sep
return [true, asarPath, filePath]
return [false, p]
# Convert asar archive's Stats object to fs's Stats object. # Convert asar archive's Stats object to fs's Stats object.
nextInode = 0 nextInode = 0