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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d0c1f294bf953936c294c496a3a116a9222505b60ea83fe910f0d6b70de0f409
|
|
4
|
+
data.tar.gz: e0da19c5cc03fa03c639da9e99eb816620c48b52aff1ccfcfdde45fb84443a6c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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(
|
|
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(
|
|
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(
|
|
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.
|
|
38
|
-
IRubyObject otherVal = other.
|
|
47
|
+
IRubyObject currentVal = self.fastARef(key);
|
|
48
|
+
IRubyObject otherVal = other.fastARef(key);
|
|
39
49
|
|
|
40
|
-
if (currentVal
|
|
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
|
-
|
|
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 =
|
|
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.
|
|
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:
|
|
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.
|
|
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.
|
|
27
|
-
source_code_uri: https://github.com/cadenza-tech/sin_deep_merge/tree/v1.0.
|
|
28
|
-
changelog_uri: https://github.com/cadenza-tech/sin_deep_merge/blob/v1.0.
|
|
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.
|
|
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:
|