foobara 0.0.67 → 0.0.68

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: a1f1ab51b7a473c588672377efea95913afc3c0f09a73a6cf34ec0133d6b9d5a
4
- data.tar.gz: b57286cf4ae31aa411b834b242055d0d8fc03f7acea41fa5a5d763e62fe02e11
3
+ metadata.gz: 790ae183ee74af5880496317c73fd548aefe37167a38b4591dedb46b67a2bf79
4
+ data.tar.gz: c057c7557d53dff6efef1ae9506b57a0fbdc0249f48cb10040de808697b7e495
5
5
  SHA512:
6
- metadata.gz: eb4ac756719ec1ce5f7953da955c02b30a59574604f3d627a9cfa57734828af9c246fa60d671dc5cfd52687371c01fca4a1d0de8ce7c165686e4272eecbef74f
7
- data.tar.gz: 867819ea9493b906f0d10d7f44cfe10bfe4370869172fba4682ebf8af2eaccf7a26e9fbe89e84b71a3177b822fe5d897362dbe419f73c79d7f2857d197bb6431
6
+ metadata.gz: b7b5571c2174ae0022efeccdbdcf053e8c2fcfa9cd152a4caf31d4f1313dd9f4ec32d0a249a88b4c59b271685e1676d0ba8537da77dd7c7e6b6a119838d40622
7
+ data.tar.gz: 243e81f88a9456cb93ded173519f79eb863779ce8957fc51fc3ba808acc24b0ad59090310b4671bfa4034adfc676bc1733c43a3e60b615b7439eb7ec414fb53d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.0.68] - 2025-02-28
2
+
3
+ - Make use of LruCache for performance boost when converting type declarations to types
4
+
1
5
  ## [0.0.67] - 2025-02-26
2
6
 
3
7
  - Convert / to _ when building constant names in Enumerated::Values
@@ -63,6 +63,8 @@ module Foobara
63
63
  attr_writer :foobara_domain_name, :foobara_full_domain_name
64
64
 
65
65
  def foobara_unregister(scoped)
66
+ foobara_type_builder.clear_cache
67
+
66
68
  if scoped.is_a?(Foobara::Types::Type)
67
69
  parent_mod = nil
68
70
 
@@ -61,6 +61,7 @@ module Foobara
61
61
  return 0 if type.nil?
62
62
  return 9 if type == value
63
63
 
64
+ # TODO: This .process_value call is slow
64
65
  return 5 if type.applicable?(value) && type.process_value(value).success?
65
66
 
66
67
  if value.is_a?(Types::Type)
@@ -1,3 +1,5 @@
1
+ require "foobara/lru_cache"
2
+
1
3
  module Foobara
2
4
  module TypeDeclarations
3
5
  class TypeBuilder
@@ -63,6 +65,12 @@ module Foobara
63
65
  end
64
66
 
65
67
  def type_for_declaration(*type_declaration_bits, &block)
68
+ lru_cache.cached([type_declaration_bits, block]) do
69
+ type_for_declaration_without_cache(*type_declaration_bits, &block)
70
+ end
71
+ end
72
+
73
+ def type_for_declaration_without_cache(*type_declaration_bits, &block)
66
74
  type_declaration = if block
67
75
  unless type_declaration_bits.empty?
68
76
  # :nocov:
@@ -88,8 +96,18 @@ module Foobara
88
96
  handler.process_value!(type_declaration)
89
97
  end
90
98
 
99
+ def clear_cache
100
+ if @lru_cache
101
+ lru_cache.reset!
102
+ end
103
+ end
104
+
91
105
  private
92
106
 
107
+ def lru_cache
108
+ @lru_cache ||= Foobara::LruCache.new(100)
109
+ end
110
+
93
111
  def type_declaration_bits_to_type_declaration(type_declaration_bits)
94
112
  type, *symbolic_processors, processor_data = type_declaration_bits
95
113
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.67
4
+ version: 0.0.68
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-26 00:00:00.000000000 Z
10
+ date: 2025-02-28 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bigdecimal
@@ -23,6 +23,20 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: foobara-lru-cache
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
26
40
  - !ruby/object:Gem::Dependency
27
41
  name: foobara-util
28
42
  requirement: !ruby/object:Gem::Requirement