diff options
| author | ruki <[email protected]> | 2025-09-27 22:05:53 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-09-27 22:05:53 +0800 |
| commit | dd07af97f1b28ed18a9cd4a66dfd574f8fc795fb (patch) | |
| tree | e949590d1ba44e536f4b08cd56c60e25fa8dd385 /xmake/core/base/scheduler.lua | |
| parent | 2bd081f1a2f21c315184a30e664b3537cfce2965 (diff) | |
| parent | 947491d0df87eafcbf8f560a1377f49a7b60a2db (diff) | |
Merge pull request #6854 from xmake-io/opti
improve os.curdir/os.cd
Diffstat (limited to 'xmake/core/base/scheduler.lua')
| -rw-r--r-- | xmake/core/base/scheduler.lua | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua index 9084ad6ba..c96b32441 100644 --- a/xmake/core/base/scheduler.lua +++ b/xmake/core/base/scheduler.lua @@ -273,18 +273,15 @@ function scheduler:_co_curdir_update(curdir) return end - -- save the current directory hash + -- save the current directory curdir = curdir or os.curdir() - local curdir_hash = hash.uuid4(path.absolute(curdir)):sub(1, 8) - self._CO_CURDIR_HASH = curdir_hash - - -- save the current directory for each coroutine local co_curdirs = self._CO_CURDIRS if not co_curdirs then co_curdirs = {} self._CO_CURDIRS = co_curdirs end - co_curdirs[running] = {curdir_hash, curdir} + co_curdirs[running] = curdir + self._CO_CURDIR_CURRENT = curdir end -- update the current environments hash of current coroutine @@ -444,10 +441,10 @@ function scheduler:co_resume(co, ...) if running then -- has the current directory been changed? restore it - local curdir = self._CO_CURDIR_HASH + local curdir = self._CO_CURDIR_CURRENT local olddir = self._CO_CURDIRS and self._CO_CURDIRS[running] or nil - if olddir and curdir ~= olddir[1] then -- hash changed? - os.cd(olddir[2]) + if olddir and curdir ~= olddir then -- hash changed? + os.cd(olddir) end -- has the current environments been changed? restore it @@ -469,10 +466,10 @@ function scheduler:co_suspend(...) -- has the current directory been changed? restore it local running = assert(self:co_running()) - local curdir = self._CO_CURDIR_HASH + local curdir = self._CO_CURDIR_CURRENT local olddir = self._CO_CURDIRS and self._CO_CURDIRS[running] or nil - if olddir and curdir ~= olddir[1] then -- hash changed? - os.cd(olddir[2]) + if olddir and curdir ~= olddir then -- hash changed? + os.cd(olddir) end -- has the current environments been changed? restore it |
