Skip to content

Commit 21e40d6

Browse files
committed
dont cache first
1 parent d9a7e4b commit 21e40d6

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

script/workspace/loading.lua

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ function mt:loadFile(uri, libraryUri)
8282
self.read = self.read + 1
8383
self:update()
8484
log.info(('Skip loaded file: %s'):format(uri))
85-
if libraryUri then
86-
log.info('++++As library of:', libraryUri)
87-
files.setLibraryUri(self.scp, uri, libraryUri)
88-
end
8985
else
9086
local content = pub.awaitTask('loadFile', furi.decode(uri))
9187
if self._cache[uri] then
@@ -98,14 +94,13 @@ function mt:loadFile(uri, libraryUri)
9894
return
9995
end
10096
log.info(('Preload file at: %s , size = %.3f KB'):format(uri, #content / 1024.0))
101-
files.setText(uri, content, false, function ()
102-
if libraryUri then
103-
log.info('++++As library of:', libraryUri)
104-
files.setLibraryUri(self.scp, uri, libraryUri)
105-
end
106-
end)
97+
files.setText(uri, content, false)
10798
end
10899
files.addRef(uri)
100+
if libraryUri then
101+
log.info('++++As library of:', libraryUri)
102+
files.setLibraryUri(self.scp, uri, libraryUri)
103+
end
109104
end
110105
elseif files.isDll(uri) then
111106
self.max = self.max + 1
@@ -116,9 +111,6 @@ function mt:loadFile(uri, libraryUri)
116111
self.read = self.read + 1
117112
self:update()
118113
log.info(('Skip loaded file: %s'):format(uri))
119-
if libraryUri then
120-
log.info('++++As library of:', libraryUri)
121-
end
122114
else
123115
local content = pub.awaitTask('loadFile', furi.decode(uri))
124116
if self._cache[uri] then
@@ -132,11 +124,11 @@ function mt:loadFile(uri, libraryUri)
132124
end
133125
log.info(('Preload dll at: %s , size = %.3f KB'):format(uri, #content / 1024.0))
134126
files.saveDll(uri, content)
135-
if libraryUri then
136-
log.info('++++As library of:', libraryUri)
137-
end
138127
end
139128
files.addRef(uri)
129+
if libraryUri then
130+
log.info('++++As library of:', libraryUri)
131+
end
140132
end
141133
end
142134
await.delay()

script/workspace/require-path.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ function m.getVisiblePath(suri, path)
4646
local libraryPath = furi.decode(files.getLibraryUri(suri, uri))
4747
local scp = scope.getScope(suri)
4848
local cache = scp:get('visiblePath') or scp:set('visiblePath', {})
49-
if not cache[path] then
50-
local result = {}
51-
cache[path] = result
49+
local result = cache[path]
50+
if not result then
51+
result = {}
52+
if libraryPath then
53+
cache[path] = result
54+
end
5255
for _, searcher in ipairs(searchers) do
5356
local isAbsolute = searcher:match '^[/\\]'
5457
or searcher:match '^%a+%:'
@@ -88,7 +91,7 @@ function m.getVisiblePath(suri, path)
8891
until not pos or strict
8992
end
9093
end
91-
return cache[path]
94+
return result
9295
end
9396

9497
--- 查找符合指定require path的所有uri

0 commit comments

Comments
 (0)