sorbet-runtime 0.5.5835 → 0.5.5841

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: 1c78c486ad11e0c1425ad311f09498c7932e29d5dc95ecd3b39d497706d918ba
4
- data.tar.gz: c465da35e7c4a3327b4f8b2b29854f45aecfb2dfabc7863245cd82028371101a
3
+ metadata.gz: 02df0e4234d0887f7584ed03f2efd4ceabe7cd2aad902a198617207b02d92a6a
4
+ data.tar.gz: 3cef81d70c297f03d9b6307c32c7c6b079e120ac5a92681ff371bb3d010205b8
5
5
  SHA512:
6
- metadata.gz: f92f74be1bb881101fab6440467307a370d063d458da5014ebfed3f768cfac7c829bcbb4200492d48d49d0d1c03d4652c4cfc9fb67edd64fc54643972a0ff332
7
- data.tar.gz: 0ff90148441a61f9cf1911fac9c6e91e065b927bb3d68a423c0371f765e11c00e4bbe3eef1b639c443603ea62a0a79ee6807ce5d54a1ab35d5bda38c23675b66
6
+ metadata.gz: 6e0cb83492e866202da027d8f8a5800a52fb7f0e3e4353952ec0250b28122704ad1bc5317ebd30b388df247d0a353afa239393aeafe3421d100d81a5f5456c81
7
+ data.tar.gz: 6a8b52a3830af73aec07c37bd6afba1081fbd47fbe0d37601803a1ccd73fa1edd08d9fbb233bb9c0556d81baff8571f791e723e7c84f117622c5fcf42ec91e40
@@ -17,11 +17,16 @@ module T::Props::Constructor::DecoratorMethods
17
17
  # checked(:never) - O(runtime object construction)
18
18
  sig {params(instance: T::Props::Constructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never)}
19
19
  def construct_props_without_defaults(instance, hash)
20
- @props_without_defaults&.count do |p, setter_proc|
20
+ # Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
21
+ # and therefore allocates for each entry.
22
+ result = 0
23
+ @props_without_defaults&.each_pair do |p, setter_proc|
21
24
  begin
22
25
  val = hash[p]
23
26
  instance.instance_exec(val, &setter_proc)
24
- val || hash.key?(p)
27
+ if val || hash.key?(p)
28
+ result += 1
29
+ end
25
30
  rescue TypeError, T::Props::InvalidValueError
26
31
  if !hash.key?(p)
27
32
  raise ArgumentError.new("Missing required prop `#{p}` for class `#{instance.class.name}`")
@@ -29,6 +34,7 @@ module T::Props::Constructor::DecoratorMethods
29
34
  raise
30
35
  end
31
36
  end
32
- end || 0
37
+ end
38
+ result
33
39
  end
34
40
  end
@@ -30,14 +30,16 @@ module T::Props::WeakConstructor::DecoratorMethods
30
30
  # checked(:never) - O(runtime object construction)
31
31
  sig {params(instance: T::Props::WeakConstructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never)}
32
32
  def construct_props_without_defaults(instance, hash)
33
- @props_without_defaults&.count do |p, setter_proc|
33
+ # Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
34
+ # and therefore allocates for each entry.
35
+ result = 0
36
+ @props_without_defaults&.each_pair do |p, setter_proc|
34
37
  if hash.key?(p)
35
38
  instance.instance_exec(hash[p], &setter_proc)
36
- true
37
- else
38
- false
39
+ result += 1
39
40
  end
40
- end || 0
41
+ end
42
+ result
41
43
  end
42
44
 
43
45
  # Set values for all props that have defaults. Use the default if and only if
@@ -49,14 +51,17 @@ module T::Props::WeakConstructor::DecoratorMethods
49
51
  # checked(:never) - O(runtime object construction)
50
52
  sig {params(instance: T::Props::WeakConstructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never)}
51
53
  def construct_props_with_defaults(instance, hash)
52
- @props_with_defaults&.count do |p, default_struct|
54
+ # Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
55
+ # and therefore allocates for each entry.
56
+ result = 0
57
+ @props_with_defaults&.each_pair do |p, default_struct|
53
58
  if hash.key?(p)
54
59
  instance.instance_exec(hash[p], &default_struct.setter_proc)
55
- true
60
+ result += 1
56
61
  else
57
62
  default_struct.set_default(instance)
58
- false
59
63
  end
60
- end || 0
64
+ end
65
+ result
61
66
  end
62
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5835
4
+ version: 0.5.5841
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-21 00:00:00.000000000 Z
11
+ date: 2020-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest