fontist 3.0.15 → 3.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fontist/formula.rb +8 -2
- data/lib/fontist/from_file_cache.rb +27 -9
- data/lib/fontist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3871228b469c6c8ee43f6bd04d6b9726feddac6fb2245f3f2bf5533b05a2baf9
|
|
4
|
+
data.tar.gz: 9e6d136e1ceaa16dd7a3907fe346bbc0a90f46a51458334a5192b5a2dea085e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a201906009471c3844a708096fea687db8aa5a8eb56efc3e13076580dfefd1fea95e12edbbe2707928f5b3ed77db326a5147bf6e043965033fc5b27586166dc2
|
|
7
|
+
data.tar.gz: b4ff402ff006a766f1daee41ffbed825f826b24c88997e9ea92a91c435fcf88545ffdf921f7091371a247b489a2dc4d0ee92faad6b11a1dfae5f2967ddcd038d
|
data/lib/fontist/formula.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "lutaml/model"
|
|
2
|
+
require "parallel"
|
|
2
3
|
require_relative "format_matcher"
|
|
3
4
|
require "git"
|
|
4
5
|
|
|
@@ -100,9 +101,14 @@ module Fontist
|
|
|
100
101
|
end
|
|
101
102
|
|
|
102
103
|
def all
|
|
103
|
-
|
|
104
|
+
paths = Dir[Fontist.formulas_path.join("**/*.yml").to_s]
|
|
105
|
+
|
|
106
|
+
# Parsing thousands of formula files dominates index rebuilds;
|
|
107
|
+
# worker threads overlap the libyaml C parse, which releases
|
|
108
|
+
# the GVL
|
|
109
|
+
formulas = Parallel.map(paths) do |path|
|
|
104
110
|
Formula.from_file(path)
|
|
105
|
-
end
|
|
111
|
+
end.compact
|
|
106
112
|
|
|
107
113
|
FormulaCollection.new(formulas)
|
|
108
114
|
end
|
|
@@ -8,21 +8,39 @@ module Fontist
|
|
|
8
8
|
# changes (e.g. after `fontist update` rewrites the formulas repo).
|
|
9
9
|
module FromFileCache
|
|
10
10
|
def self.memoize(path)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
mtime = File.mtime(path)
|
|
12
|
+
|
|
13
|
+
hit = current_value(path, mtime)
|
|
14
|
+
return hit if hit
|
|
15
|
+
|
|
16
|
+
# Parse without holding the lock so parallel readers (e.g.
|
|
17
|
+
# Formula.all over worker threads) overlap; concurrent misses on
|
|
18
|
+
# the same path may duplicate work but write identical values
|
|
19
|
+
value = yield
|
|
20
|
+
|
|
21
|
+
store(path, mtime, value)
|
|
22
|
+
|
|
23
|
+
value
|
|
20
24
|
end
|
|
21
25
|
|
|
22
26
|
def self.clear
|
|
23
27
|
mutex.synchronize { cache.clear }
|
|
24
28
|
end
|
|
25
29
|
|
|
30
|
+
def self.current_value(path, mtime)
|
|
31
|
+
hit = mutex.synchronize { cache[path] }
|
|
32
|
+
hit&.fetch(:mtime, nil) == mtime ? hit[:value] : nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.store(path, mtime, value)
|
|
36
|
+
mutex.synchronize do
|
|
37
|
+
existing = cache[path]
|
|
38
|
+
if existing.nil? || existing[:mtime] != mtime
|
|
39
|
+
cache[path] = { mtime: mtime, value: value }
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
26
44
|
def self.mutex
|
|
27
45
|
@mutex ||= Mutex.new
|
|
28
46
|
end
|
data/lib/fontist/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fontist
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: down
|