|
9 | 9 | */
|
10 | 10 | package org.truffleruby.core.hash;
|
11 | 11 |
|
12 |
| -import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; |
13 | 12 | import org.truffleruby.Layouts;
|
14 | 13 | import org.truffleruby.RubyContext;
|
15 | 14 | import org.truffleruby.core.cast.BooleanCastNode;
|
@@ -72,33 +71,37 @@ public SmallHashLiteralNode(RubyNode[] keyValues) {
|
72 | 71 | super(keyValues);
|
73 | 72 | }
|
74 | 73 |
|
75 |
| - @ExplodeLoop(kind = LoopExplosionKind.FULL_UNROLL) |
| 74 | + @ExplodeLoop |
76 | 75 | @Override
|
77 | 76 | public Object execute(VirtualFrame frame) {
|
78 | 77 | final Object[] store = PackedArrayStrategy.createStore(getContext());
|
79 | 78 |
|
80 | 79 | int size = 0;
|
81 | 80 |
|
82 |
| - initializers: for (int n = 0; n < keyValues.length / 2; n++) { |
| 81 | + for (int n = 0; n < keyValues.length / 2; n++) { |
83 | 82 | Object key = keyValues[n * 2].execute(frame);
|
84 | 83 | key = freezeHashKeyIfNeededNode.executeFreezeIfNeeded(key, false);
|
85 | 84 |
|
86 | 85 | final int hashed = hash(key);
|
87 | 86 |
|
88 | 87 | final Object value = keyValues[n * 2 + 1].execute(frame);
|
| 88 | + boolean duplicateKey = false; |
89 | 89 |
|
90 | 90 | for (int i = 0; i < n; i++) {
|
91 | 91 | if (i < size &&
|
92 | 92 | hashed == PackedArrayStrategy.getHashed(store, i) &&
|
93 | 93 | callEqual(key, PackedArrayStrategy.getKey(store, i))) {
|
94 | 94 | PackedArrayStrategy.setKey(store, i, key);
|
95 | 95 | PackedArrayStrategy.setValue(store, i, value);
|
96 |
| - continue initializers; |
| 96 | + duplicateKey = true; |
| 97 | + break; |
97 | 98 | }
|
98 | 99 | }
|
99 | 100 |
|
100 |
| - PackedArrayStrategy.setHashedKeyValue(store, size, hashed, key, value); |
101 |
| - size++; |
| 101 | + if (!duplicateKey) { |
| 102 | + PackedArrayStrategy.setHashedKeyValue(store, size, hashed, key, value); |
| 103 | + size++; |
| 104 | + } |
102 | 105 | }
|
103 | 106 |
|
104 | 107 | return coreLibrary()
|
|
0 commit comments