rice 4.3.2 → 4.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f1560a877de281b9d1fb0538591d606dc0fe312a6fbbaaf9d15448028836fad
4
- data.tar.gz: 0af73222a775ef41799404a26c4cd69290330ce41184b512ecfb1a2d05925900
3
+ metadata.gz: 20166e7dba31a0e143cdc5a0be57c36a61ae93975ff2aaefbb1682e55382a40d
4
+ data.tar.gz: dff13c1a5eb9ea2672754cd30ddcd817d7865c497f6869f34dc920cfb3d0f111
5
5
  SHA512:
6
- metadata.gz: 426d8192d42f45b177a4f8639dc7d329143c2a5874b3ead5ab71bdcf0299d46d0e0d707cb616e57c33f2c2896aba7497baaba3191d02ab846ac2b2b49abe3071
7
- data.tar.gz: d3cab1776f0817e76ee2d0576c8addf3412bf16d0da5fbcb64232d5aa9887b7f9c3607878e201cc9677e387ec4253a61add0be845e46bfa6751d261b4d596815
6
+ metadata.gz: 4afced2db4bb7f4b5eb2520a5a0d297acf74a738ae2932225ecf2be9c10348cb426252c40f0204f651389d5823aae996065278262101685a2f64e65c0e2472e8
7
+ data.tar.gz: 8c2293c0d4159954e7640c148865b51e8263c02ce7b35c3a18d4b5b56c35c853007b8b88799265ab4f389455006fa179a089888791c6c6d88f79a85d95f448fe
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 4.3.3
2
+
3
+ * Fix complication issue on Ubuntu 20.04 and GCC 9.
4
+
1
5
  ## 4.3.2
2
6
 
3
7
  * Improve NativeRegistry to reduce possible hash collisions and weird "bad any cast" errors.
@@ -1075,7 +1075,6 @@ namespace Rice::detail
1075
1075
 
1076
1076
  #include <unordered_map>
1077
1077
  #include <any>
1078
- #include <tuple>
1079
1078
 
1080
1079
 
1081
1080
  namespace Rice::detail
@@ -1094,8 +1093,7 @@ namespace Rice::detail
1094
1093
  Return_T lookup(VALUE klass, ID method_id);
1095
1094
 
1096
1095
  private:
1097
- size_t key(VALUE klass, ID method_id);
1098
- std::unordered_multimap<size_t, std::tuple<VALUE, ID, std::any>> natives_ = {};
1096
+ std::unordered_multimap<ID, std::pair<VALUE, std::any>> natives_ = {};
1099
1097
  };
1100
1098
  }
1101
1099
 
@@ -1111,14 +1109,6 @@ namespace Rice::detail
1111
1109
 
1112
1110
  namespace Rice::detail
1113
1111
  {
1114
- // Effective Java (2nd edition)
1115
- // https://stackoverflow.com/a/2634715
1116
- inline size_t NativeRegistry::key(VALUE klass, ID id)
1117
- {
1118
- uint32_t prime = 53;
1119
- return (prime + klass) * prime + id;
1120
- }
1121
-
1122
1112
  inline void NativeRegistry::add(VALUE klass, ID method_id, std::any callable)
1123
1113
  {
1124
1114
  if (rb_type(klass) == T_ICLASS)
@@ -1126,19 +1116,19 @@ namespace Rice::detail
1126
1116
  klass = detail::protect(rb_class_of, klass);
1127
1117
  }
1128
1118
 
1129
- auto range = this->natives_.equal_range(key(klass, method_id));
1119
+ auto range = this->natives_.equal_range(method_id);
1130
1120
  for (auto it = range.first; it != range.second; ++it)
1131
1121
  {
1132
- const auto [k, m, d] = it->second;
1122
+ const auto [k, d] = it->second;
1133
1123
 
1134
- if (k == klass && m == method_id)
1124
+ if (k == klass)
1135
1125
  {
1136
- std::get<2>(it->second) = callable;
1126
+ std::get<1>(it->second) = callable;
1137
1127
  return;
1138
1128
  }
1139
1129
  }
1140
1130
 
1141
- this->natives_.emplace(std::make_pair(key(klass, method_id), std::make_tuple(klass, method_id, callable)));
1131
+ this->natives_.emplace(std::make_pair(method_id, std::make_pair(klass, callable)));
1142
1132
  }
1143
1133
 
1144
1134
  template <typename Return_T>
@@ -1162,12 +1152,12 @@ namespace Rice::detail
1162
1152
  klass = detail::protect(rb_class_of, klass);
1163
1153
  }
1164
1154
 
1165
- auto range = this->natives_.equal_range(key(klass, method_id));
1155
+ auto range = this->natives_.equal_range(method_id);
1166
1156
  for (auto it = range.first; it != range.second; ++it)
1167
1157
  {
1168
- const auto [k, m, d] = it->second;
1158
+ const auto [k, d] = it->second;
1169
1159
 
1170
- if (k == klass && m == method_id)
1160
+ if (k == klass)
1171
1161
  {
1172
1162
  auto* ptr = std::any_cast<Return_T>(&d);
1173
1163
  if (!ptr)
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rice
2
- VERSION = "4.3.2"
2
+ VERSION = "4.3.3"
3
3
  end
@@ -3,7 +3,6 @@
3
3
 
4
4
  #include <unordered_map>
5
5
  #include <any>
6
- #include <tuple>
7
6
 
8
7
  #include "ruby.hpp"
9
8
 
@@ -23,8 +22,7 @@ namespace Rice::detail
23
22
  Return_T lookup(VALUE klass, ID method_id);
24
23
 
25
24
  private:
26
- size_t key(VALUE klass, ID method_id);
27
- std::unordered_multimap<size_t, std::tuple<VALUE, ID, std::any>> natives_ = {};
25
+ std::unordered_multimap<ID, std::pair<VALUE, std::any>> natives_ = {};
28
26
  };
29
27
  }
30
28
  #include "NativeRegistry.ipp"
@@ -10,14 +10,6 @@
10
10
 
11
11
  namespace Rice::detail
12
12
  {
13
- // Effective Java (2nd edition)
14
- // https://stackoverflow.com/a/2634715
15
- inline size_t NativeRegistry::key(VALUE klass, ID id)
16
- {
17
- uint32_t prime = 53;
18
- return (prime + klass) * prime + id;
19
- }
20
-
21
13
  inline void NativeRegistry::add(VALUE klass, ID method_id, std::any callable)
22
14
  {
23
15
  if (rb_type(klass) == T_ICLASS)
@@ -25,19 +17,19 @@ namespace Rice::detail
25
17
  klass = detail::protect(rb_class_of, klass);
26
18
  }
27
19
 
28
- auto range = this->natives_.equal_range(key(klass, method_id));
20
+ auto range = this->natives_.equal_range(method_id);
29
21
  for (auto it = range.first; it != range.second; ++it)
30
22
  {
31
- const auto [k, m, d] = it->second;
23
+ const auto [k, d] = it->second;
32
24
 
33
- if (k == klass && m == method_id)
25
+ if (k == klass)
34
26
  {
35
- std::get<2>(it->second) = callable;
27
+ std::get<1>(it->second) = callable;
36
28
  return;
37
29
  }
38
30
  }
39
31
 
40
- this->natives_.emplace(std::make_pair(key(klass, method_id), std::make_tuple(klass, method_id, callable)));
32
+ this->natives_.emplace(std::make_pair(method_id, std::make_pair(klass, callable)));
41
33
  }
42
34
 
43
35
  template <typename Return_T>
@@ -61,12 +53,12 @@ namespace Rice::detail
61
53
  klass = detail::protect(rb_class_of, klass);
62
54
  }
63
55
 
64
- auto range = this->natives_.equal_range(key(klass, method_id));
56
+ auto range = this->natives_.equal_range(method_id);
65
57
  for (auto it = range.first; it != range.second; ++it)
66
58
  {
67
- const auto [k, m, d] = it->second;
59
+ const auto [k, d] = it->second;
68
60
 
69
- if (k == klass && m == method_id)
61
+ if (k == klass)
70
62
  {
71
63
  auto* ptr = std::any_cast<Return_T>(&d);
72
64
  if (!ptr)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rice
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.2
4
+ version: 4.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Brannan
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-10-18 00:00:00.000000000 Z
13
+ date: 2024-10-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler