sin_deep_merge 1.0.0-java → 1.0.1-java

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: 4ecfab1fe791f3186e8e8b2e6875388570960c3f16d6f09d7e99503c7963b722
4
- data.tar.gz: e5dee299cedfbe2d99eb7483232563b5a9ec00e734de70adcef2fa394a2e3ea3
3
+ metadata.gz: d0c1f294bf953936c294c496a3a116a9222505b60ea83fe910f0d6b70de0f409
4
+ data.tar.gz: e0da19c5cc03fa03c639da9e99eb816620c48b52aff1ccfcfdde45fb84443a6c
5
5
  SHA512:
6
- metadata.gz: 3dabb3b0aadbf33d484012d0b788edb0652fe6b1dd81caa895dfec5901574fc06dc5824b9ff6527007610f58378ccc04982bdd16259520e086a747766b8b4f60
7
- data.tar.gz: 5f460016c5fb13809dbf0f5778627e2d857a9f42655d76caa3de5fc7088e06d1f9ff6bb0de1607be8a8616d604951542525a5a7bc52614292608749736217ada
6
+ metadata.gz: ba916aff9607573eea347b6b400b8b84fb4797810b557e4f6cb6f5704712828c06c575b0973e69c11664542635463307455b1abfa9ee000f2fb8acfee32c417b
7
+ data.tar.gz: 2fe051716c036e3908eaa65051fede2bf57acaa8518636e86596d6df0881d5e7f76544492fb45611a600ab2495ec298e2665b5b9a75feaf703fed712a1acd53b
@@ -15,38 +15,51 @@ public class SinDeepMergeLibrary implements Library {
15
15
  }
16
16
 
17
17
  @JRubyMethod(name = "deep_merge", required = 1)
18
- public static IRubyObject deepMerge(ThreadContext context, IRubyObject self, IRubyObject other, Block block) {
18
+ public static IRubyObject deepMerge(
19
+ ThreadContext context, IRubyObject self, IRubyObject other, Block block) {
19
20
  RubyHash selfHash = self.convertToHash();
20
21
  RubyHash dupedHash = (RubyHash) selfHash.dup();
21
22
  RubyHash otherHash = other.convertToHash();
22
- deepMergeHashes(context, dupedHash, otherHash, block);
23
+ deepMergeHashes(context, dupedHash, otherHash, block, false);
23
24
  return dupedHash;
24
25
  }
25
26
 
26
27
  @JRubyMethod(name = "deep_merge!", required = 1)
27
- public static IRubyObject deepMergeBang(ThreadContext context, IRubyObject self, IRubyObject other, Block block) {
28
+ public static IRubyObject deepMergeBang(
29
+ ThreadContext context, IRubyObject self, IRubyObject other, Block block) {
28
30
  RubyHash selfHash = self.convertToHash();
31
+ if (selfHash.isFrozen()) {
32
+ throw context.runtime.newFrozenError("Hash");
33
+ }
29
34
  RubyHash otherHash = other.convertToHash();
30
- deepMergeHashes(context, selfHash, otherHash, block);
35
+ deepMergeHashes(context, selfHash, otherHash, block, true);
31
36
  return selfHash;
32
37
  }
33
38
 
34
- private static void deepMergeHashes(ThreadContext context, RubyHash self, RubyHash other, Block block) {
39
+ private static void deepMergeHashes(
40
+ ThreadContext context,
41
+ RubyHash self,
42
+ RubyHash other,
43
+ Block block,
44
+ boolean destructive) {
35
45
  for (Object k : other.keySet()) {
36
46
  IRubyObject key = (IRubyObject) k;
37
- IRubyObject currentVal = self.op_aref(context, key);
38
- IRubyObject otherVal = other.op_aref(context, key);
47
+ IRubyObject currentVal = self.fastARef(key);
48
+ IRubyObject otherVal = other.fastARef(key);
39
49
 
40
- if (currentVal.isNil()) {
50
+ if (currentVal == null) {
41
51
  self.op_aset(context, key, otherVal);
42
52
  } else if (currentVal instanceof RubyHash && otherVal instanceof RubyHash) {
43
53
  RubyHash currentHash = (RubyHash) currentVal;
44
- currentHash = (RubyHash) currentHash.dup();
45
54
  RubyHash otherHash = (RubyHash) otherVal;
46
- deepMergeHashes(context, currentHash, otherHash, block);
55
+ if (!destructive) {
56
+ currentHash = (RubyHash) currentHash.dup();
57
+ }
58
+ deepMergeHashes(context, currentHash, otherHash, block, destructive);
47
59
  self.op_aset(context, key, currentHash);
48
60
  } else if (block.isGiven()) {
49
- IRubyObject result = block.call(context, new IRubyObject[] { key, currentVal, otherVal });
61
+ IRubyObject result =
62
+ block.call(context, new IRubyObject[] {key, currentVal, otherVal});
50
63
  self.op_aset(context, key, result);
51
64
  } else {
52
65
  self.op_aset(context, key, otherVal);
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sin_deep_merge
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: java
6
6
  authors:
7
7
  - Masahiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-11 00:00:00.000000000 Z
11
+ date: 2026-02-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Merge deeply nested hashes faster than DeepMerge or ActiveSupport
14
14
  email:
@@ -19,15 +19,15 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - ext/java/sin_deep_merge/SinDeepMergeLibrary.java
21
21
  - lib/sin_deep_merge/sin_deep_merge.jar
22
- homepage: https://github.com/cadenza-tech/sin_deep_merge/tree/v1.0.0
22
+ homepage: https://github.com/cadenza-tech/sin_deep_merge/tree/v1.0.1
23
23
  licenses:
24
24
  - MIT
25
25
  metadata:
26
- homepage_uri: https://github.com/cadenza-tech/sin_deep_merge/tree/v1.0.0
27
- source_code_uri: https://github.com/cadenza-tech/sin_deep_merge/tree/v1.0.0
28
- changelog_uri: https://github.com/cadenza-tech/sin_deep_merge/blob/v1.0.0/CHANGELOG.md
26
+ homepage_uri: https://github.com/cadenza-tech/sin_deep_merge/tree/v1.0.1
27
+ source_code_uri: https://github.com/cadenza-tech/sin_deep_merge/tree/v1.0.1
28
+ changelog_uri: https://github.com/cadenza-tech/sin_deep_merge/blob/v1.0.1/CHANGELOG.md
29
29
  bug_tracker_uri: https://github.com/cadenza-tech/sin_deep_merge/issues
30
- documentation_uri: https://rubydoc.info/gems/sin_deep_merge/1.0.0
30
+ documentation_uri: https://rubydoc.info/gems/sin_deep_merge/1.0.1
31
31
  funding_uri: https://patreon.com/CadenzaTech
32
32
  rubygems_mfa_required: 'true'
33
33
  post_install_message: