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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e34cf04876b1c50b7ada12a6d8c23a1954baaecc499433d25844f2c0df899c97
4
- data.tar.gz: 3728d8848dd1eb1d92ef0f7b28d251e1f9ef3a9d5d3ec7592f39607f05d9b3d0
3
+ metadata.gz: 3871228b469c6c8ee43f6bd04d6b9726feddac6fb2245f3f2bf5533b05a2baf9
4
+ data.tar.gz: 9e6d136e1ceaa16dd7a3907fe346bbc0a90f46a51458334a5192b5a2dea085e9
5
5
  SHA512:
6
- metadata.gz: 415419b02587672d1e4676365a2658f0d126f1860a2b67f22aef5509dcb14268deab6db07847b655151612247b94d029bfb9cea65352b8d80a41b017f6c97b76
7
- data.tar.gz: 6cab85a340fb53f66d2ba771de09aa6d13a882a98aeb60ffd806da24207a669b61e8d9e57f59821107f6231f5b1070f18a107fde561289d787a32fb2afd3ca09
6
+ metadata.gz: a201906009471c3844a708096fea687db8aa5a8eb56efc3e13076580dfefd1fea95e12edbbe2707928f5b3ed77db326a5147bf6e043965033fc5b27586166dc2
7
+ data.tar.gz: b4ff402ff006a766f1daee41ffbed825f826b24c88997e9ea92a91c435fcf88545ffdf921f7091371a247b489a2dc4d0ee92faad6b11a1dfae5f2967ddcd038d
@@ -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
- formulas = Dir[Fontist.formulas_path.join("**/*.yml").to_s].filter_map do |path|
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
- mutex.synchronize do
12
- mtime = File.mtime(path)
13
- entry = cache[path]
14
- if entry.nil? || entry[:mtime] != mtime
15
- entry = { mtime: mtime, value: yield }
16
- cache[path] = entry
17
- end
18
- entry[:value]
19
- end
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
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "3.0.15".freeze
2
+ VERSION = "3.0.16".freeze
3
3
  end
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.15
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-10-31 00:00:00.000000000 Z
11
+ date: 2026-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down