mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
🐎 Test for prefix without calling path.join
Directory::relativize is called many times by the fuzzy finder and using path.join possibly multiple times per call was consuming much of the time take to show the fuzzy finder view.
This commit is contained in:
@@ -73,11 +73,11 @@ class Directory
|
||||
|
||||
if fullPath is @getPath()
|
||||
''
|
||||
else if fullPath.indexOf(path.join(@getPath(), path.sep)) is 0
|
||||
else if @isPathPrefixOf(@getPath(), fullPath)
|
||||
fullPath.substring(@getPath().length + 1)
|
||||
else if fullPath is @getRealPathSync()
|
||||
''
|
||||
else if fullPath.indexOf(path.join(@getRealPathSync(), path.sep)) is 0
|
||||
else if @isPathPrefixOf(@getRealPathSync(), fullPath)
|
||||
fullPath.substring(@getRealPathSync().length + 1)
|
||||
else
|
||||
fullPath
|
||||
@@ -139,3 +139,7 @@ class Directory
|
||||
if @watchSubscription?
|
||||
@watchSubscription.close()
|
||||
@watchSubscription = null
|
||||
|
||||
# Private: Does given full path start with the given prefix?
|
||||
isPathPrefixOf: (prefix, fullPath) ->
|
||||
fullPath.indexOf(prefix) is 0 and fullPath[prefix.length] is path.sep
|
||||
|
||||
Reference in New Issue
Block a user