未验证 提交 76df3927 编写于 作者: E Eugene Auduchinok 提交者: GitHub

Intern namespace parts (#12169)

上级 85fe2809
......@@ -52,6 +52,17 @@ type PrimaryAssembly =
// Utilities: type names
// --------------------------------------------------------------------
/// Global State. All namespace splits ever seen
// ++GLOBAL MUTABLE STATE (concurrency-safe)
let memoizeNamespaceTable = ConcurrentDictionary<string, string list>()
// ++GLOBAL MUTABLE STATE (concurrency-safe)
let memoizeNamespaceRightTable = ConcurrentDictionary<string, string option * string>()
// ++GLOBAL MUTABLE STATE (concurrency-safe)
let memoizeNamespacePartTable = ConcurrentDictionary<string, string>()
let splitNameAt (nm: string) idx =
if idx < 0 then failwith "splitNameAt: idx < 0"
let last = nm.Length - 1
......@@ -64,15 +75,9 @@ let rec splitNamespaceAux (nm: string) =
| -1 -> [nm]
| idx ->
let s1, s2 = splitNameAt nm idx
let s1 = memoizeNamespacePartTable.GetOrAdd(s1, id)
s1 :: splitNamespaceAux s2
/// Global State. All namespace splits ever seen
// ++GLOBAL MUTABLE STATE (concurrency-safe)
let memoizeNamespaceTable = ConcurrentDictionary<string, string list>()
// ++GLOBAL MUTABLE STATE (concurrency-safe)
let memoizeNamespaceRightTable = ConcurrentDictionary<string, string option * string>()
let splitNamespace nm =
memoizeNamespaceTable.GetOrAdd (nm, splitNamespaceAux)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册