Skip to content

Commit 42ec659

Browse files
committed
fix: memoize the rababa diacritizer per config
A single global cache meant the first config built served every later call — the missing-config error could never fire once any rababa map had run (the CI sweep does), and two configs in one process silently shared one diacritizer. Keyed per config; reset_cache clears the map.
1 parent a66770a commit 42ec659

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎lib/interscript/stdlib/functions/rababa_adapter.rb‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Interscript::Stdlib
22
module Functions
33
class RababaAdapter
4-
@rababa_diacritizer = nil
4+
@rababa_diacritizers = {}
55
@mutex = Mutex.new
66

77
class << self
@@ -18,15 +18,15 @@ def reverse(output, config: nil)
1818
end
1919

2020
def reset_cache
21-
@mutex.synchronize { @rababa_diacritizer = nil }
21+
@mutex.synchronize { @rababa_diacritizers.clear }
2222
end
2323

2424
private
2525

2626
def diacritizer_for(config_key)
2727
require_rababa!
2828
@mutex.synchronize do
29-
@rababa_diacritizer ||= build_diacritizer(config_key)
29+
@rababa_diacritizers[config_key] ||= build_diacritizer(config_key)
3030
end
3131
end
3232

0 commit comments

Comments
 (0)