blob: b920387ddbd4eb49e891da9b9cab60c99f936992 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
local searcher = require 'searcher.searcher'
local library = require 'library'
local function getLibrary(source)
local globalName = searcher.getGlobal(source)
if not globalName then
return nil
end
local name = globalName:match '^s|(.+)$'
if library.global[name] then
return library.global[name]
end
return nil
end
function searcher.getLibrary(source)
local cache = searcher.cache.getLibrary[source]
if cache ~= nil then
return cache
end
local unlock = searcher.lock('getLibrary', source)
if not unlock then
return
end
cache = getLibrary(source) or false
searcher.cache.getLibrary[source] = cache
unlock()
return cache
end
|